meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Last revisionBoth sides next revision
programming:python:socket [2023/12/28 14:04] – created niziakprogramming:python:socket [2023/12/28 14:05] niziak
Line 7: Line 7:
   * read() reads until EOF, so EOF for sockets means that connection is closed. Workarounds:   * 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 ''\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.+    * use own framing protocol. I.e. Encode 32bit size on first 4 bytes (using ''struct''). Then send data payload. On receiver side: read exactly 4 bytes and then N bytes specified in header.