110,539
社区成员
发帖
与我相关
我的任务
分享
while (sendCount < ms.Length)//分块传送,可是服务器端每次都接收一个新的socket,如何知道图片传送完了啊????????
{
sendBuf = new Byte[1024];
int count = ms.Read(sendBuf, 0, sendBuf.Length); //从图片中读出数据
//ns.Write(sendBuf,0, count);
c.Send(sendBuf, sendBuf.Length, 0);
sendCount += count;
}
Byte[] buffer = new Byte[1024];
int count = sk.Receive(buffer);
while (count != 0)
{
try
{
ms.Write(buffer, 0, count); //写入内存流
buffer = new Byte[1024];
Byte[] tempbuff = new Byte[1024];
count = sk.Receive(tempbuff);
buffer = tempbuff;
}
catch (Exception ex)
{ }
}
Image image = Image.FromStream(ms);
picScreen.Image = image;
ms.Flush();
ms = new MemoryStream();
s.Close();
SOCKET 说了:TcpListener 小样别以为你穿了马甲我就不认识你了。