Topic: 能否在1个Socket上面建立2个或者多个输入,输出流? |
Print this page |
1.能否在1个Socket上面建立2个或者多个输入,输出流? | Copy to clipboard |
Posted by: oath911 Posted on: 2005-05-31 10:21 Socket通信, 能否在1个Socket上面建立2个或者多个输入,输出流??? 意思是我又想发送文件-DataInputStream(); 又想显示对方输入-PrintStream(); 可以吗?如果可以,多个流是不是能够同时存在? 还是PrintStream()用完,close之后,再建立DataInputStream(); |
2.Re:能否在1个Socket上面建立2个或者多个输入,输出流? [Re: oath911] | Copy to clipboard |
Posted by: littledeer1974 Posted on: 2005-05-31 10:44 我没有做深入的调查,以下发言仅供参考 我觉得一个SOCKET和一个流对应 你的需求也许可以通过再生成一个SOCKET来实现 (另外不要用无意义的回贴来顶贴,谢谢合作) |
3.Re:能否在1个Socket上面建立2个或者多个输入,输出流? [Re: oath911] | Copy to clipboard |
Posted by: henryevol Posted on: 2005-06-03 17:20 可以把从socket获得的inputStream 套上两个流,对这两个流的操作,本质还是对 socket获得的那一个inputStream的操作,所以,读流的顺序性应自己保证,不能使用两个线程,同时读那两个流,如果那样 获得数据就没意义了 |
4.Re:能否在1个Socket上面建立2个或者多个输入,输出流? [Re: oath911] | Copy to clipboard |
Posted by: ftang Posted on: 2005-06-03 23:07 no, you can't...Don't waste time on this...I had this problem loooong time back...that was socket pool project, and "accidentally" I assigned the same socket to the different threads...multiple stream over 1 socket...the result is stream step over each-other... the content u read from stream is totally messed up...I was almost dead when I sniff that problem.... |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |