Search code examples
javasocketsnetworkingsendlisten

Send on Socket while listening


I have programmed (in JAVA) a socket using simple examples in the web. I can either send or listen at one time - as far as I understood.

Isn't there a possibility where I can send/listen/receive full duplex?

Thank you very much.


Solution

  • You can send and receive using two different threads. If you have one thread reading you can have another writing. The reading thread need to be waiting all the time if you use a blocking socket. You only need a writing thread when you have something to send.