On the network I am writing, I need to send and receive messages through a TCP socket. Messages can be sent or received at any time, that is, they must work as a full duplex channel.
I managed to implement such a scenario using two threads: the main thread calling send (), and the dedicated thread, which was mostly blocked when recv () was called.
My question is: is it possible to implement the same scenario with a single thread? That is, by registering some callback function?
As a side note: I need to implement this script in C ++, Java and Python.
source
share