0

In Python, how would I go about writing a TCP SocketServer receiving a string until a NUL character (\0) is found? After the string is received fully, I need the socket to continue to be able to receive new strings.

chyyran
  • 2,446
  • 2
  • 21
  • 35
  • @Celada I don't have any code besides a basic SocketServer (self.request.recv(1024)), I honestly have no idea how to do this, therefore, I need help – chyyran Feb 23 '13 at 02:17

1 Answers1

0

On reading the documentation you want to use "the alternative request handler class that makes use of streams (file-like objects that simplify communication by providing the standard file interface)":

class MyTCPHandler(socketserver.StreamRequestHandler):

Once you have a file like interface you can extract the bytes till you get the '\0' NUL character. You'll block on the read() requests.

Arcturus
  • 550
  • 2
  • 6