JavaTcpSocket icon indicating copy to clipboard operation
JavaTcpSocket copied to clipboard

崩溃了,为什么这服务器例程,我用其他TCP调试助手都发不出数据?

Open SSSANTON opened this issue 8 years ago • 4 comments

能看到客户端(网上下载的三个TCP调试助手,有一个是我一直惯用的)连接上或断开连接,但客户端发送数据,服务器死活收不到数据,OnReceived中一直没有响应。 运行你的client-desktop例程,却能正常发送,这么什么原因。。。。。。

SSSANTON avatar Oct 10 '16 08:10 SSSANTON

似乎是编码对不上还是堵塞之类的问题, 改成下面这样就行了==

while (runFlag) { try { byte[] buffer = new byte[8192]; int readSize= in.read(buffer); if(readSize == 0)continue; if(readSize>0) { String content = new String(buffer, 0, readSize); this.onReceive(addr, content); }

SSSANTON avatar Oct 10 '16 09:10 SSSANTON

@SSSANTON 我的也是遇到你说的问题 你这修改代码是否可以贴全一点?

youngchen1987 avatar Sep 04 '17 06:09 youngchen1987

改好了

youngchen1987 avatar Sep 04 '17 06:09 youngchen1987

上面方法可用。谢了

bluelemo avatar Jul 15 '19 14:07 bluelemo