写入后保持NetworkStream打开 [英] Keeping NetworkStream Open After Write

查看:82
本文介绍了写入后保持NetworkStream打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个TCP服务器和客户端.客户端使用NetworkStream.Write将图像发送到服务器,然后服务器接收数据并将其显示在图片框中,这在第一次运行时效果很好.但是,每当客户端尝试发送另一个图像时,流就会被锁定.如果我使用NetworkSteam.Close(),则重新打开它并使其正常工作,但我想保持流在整个时间内一直打开并接收多张图像.我该怎么做呢?

预先感谢,
Turtle

I have a TCP server and Client. The client sends an image to the server using NetworkStream.Write, the server then receives the data and displays it into a picturebox, this works fine the first time. But everytime the Client trys to send another image the stream locks up. If i use NetworkSteam.Close() then reopen it and get the stream it works, but i would like to keep the stream open the entire time and receive multiple images. How could i go about doing this?

Thanks in advance,
Turtle

推荐答案

我会说它正在按设计运行,因此您不应该保持流打开.如果您一直将数据追加到流中,接收方应用程序将如何知道何时停止接收和显示图像?
I would say it is functioning as designed and you should not keep the stream open. If you keep appending data to the stream how would the receiving app know when to stop receiving and display the image?


这篇关于写入后保持NetworkStream打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆