meta data for this page
  •  

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
programming:python:socket [2023/12/28 14:05] โ€“ niziakprogramming:python:socket [2023/12/28 14:23] (current) โ€“ niziak
Line 1: Line 1:
 ====== socket ====== ====== socket ======
  
 +[[https://docs.python.org/3/library/socket.html|socket โ€” Low-level networking interface]]
 ===== socket.makefile ===== ===== socket.makefile =====
 +
 +[[https://docs.python.org/3/library/socket.html#socket.socket.makefile|socket.makefile]]
  
 When accessing socket as file: When accessing socket as file:
Line 8: Line 11:
     * 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. 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.     * 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.
 +  * When file is in binary ''b'' mode, use ''str.encode()'' to convert strings into bytes
 +
 +
 +