简体   繁体   中英

java socket full duplex

Is it possible to have a server and a client with 1 socket connection and send data in both directions at the same time? I mean both the server and the client reads and writes on the same time (2 threads in each process)

Edit: I need "true" two-way communications and not the request / response kind of communication. Both the client and the server must be able to write at the same time.

Edit2: God Dame! It works. Silly me I had a deadlock between client/server because of a write in the reader thread! :) Thanks

Yes, it seems use Threads each for sending and receiving on both sides. So one socket connection can do that.

TCP连接是一个全双工字节流 ,所以是的,您可以同时读取和写入同一个套接字,但您当然不必使用线程进行双向通信。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM