meta data for this page
  •  

This is an old revision of the document!


socket

socket.makefile

When accessing socket as file:

  • remember to call file.flush() after file.write()
  • read() reads until EOF, so EOF for sockets means that connection is closed. Workarounds:
    • use \n at end of message and readline() for reading
    • use own framing protocol. I.e. first 4 bytes is always size of data payload and first read exactly 4 bytes and then N bytes specified in header.