作者kekul (每天都肚子饿)
看板C_Sharp
标题[问题] 请教一个 TcpListener 问题
时间Wed May 30 16:00:00 2007
我写了一个 Server/Client 程式
需求是 Server 一接到 Client 丢的一串 binary data (Byte[])
就立刻对这段 binary data 做处理
但我发现资料似乎会塞在缓冲区,累积到一定程度再一口气丢
所以在 Client Side 这端设定 tcpclient.NoDelay = true;
接着,在 Server 跟 Client 中间写个小程式验证
Client 也照预期每次 networkstream.write 时就将 data 丢出
但问题就出在 Server 这端
(Server 这端我用 TcpListner 去做
开 thread 後用 networkstream.BeginRead 去接)
Server 似乎还是会缓冲起来
累积到一定的资料才抛出来
我试着将 tcplistener.Server.NoDelay = true;
或是将 listener.AcceptTcpClient() 接来的 tcpclient.NoDelay = true;
似乎都无法让 data 一接到就丢出来
请问是否有什麽方式可以解决这个问题呢??
在此先谢谢各位 ^^
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 116.59.125.16
1F:推 cole945:你应该是要设定Blocking=false而不是设定NoDelay.. 05/30 16:57
2F:→ cole945:还有"如果"你有透过什麽iostream去送资料给socket再送出.. 05/30 16:58
3F:→ cole945:要注意那个iostream本身可能也会缓冲资料.. 05/30 16:59