I have a socket client and a socket server.
The server is in python, and is synchronous.
Sometimes the clients send an empty string, and I'm then required to identify this situation, and return a response.
With the code below, the server just keeps on waiting, and the clients don't get anything in return, unless it sends something more "fat" (i.e. a longer message).
How can I capture the empty message? Is it at all possible?
This is my server code:
import SocketServer
def multi_threaded_socket_server():
class MyRequestHandler(SocketServer.BaseRequestHandler):
def handle(self):
while True:
print 'waiting for client calls...'
received = self.request.recv( PACKET_SIZE )
(handle request... )
As you describe a multi-threaded socket server, it would seem to be TCP, in which case your requirement doesn't make sense. You can't send an empty message over TCP. You would have to use a superimposed protocol for everything.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With