I'm writing a server which accepts TCP connections and reads arbitrary-length lines of data terminated by a \n
.
For this the semantics of socket.makefile(...).readline() does exactly what I need it to:
f = socket.makefile(mode="rb")
while True:
data = f.readline()
print(data.decode('utf-8'))
if not data:
break
However, there's an open issue on CPython alleging a performance issue:
https://github.com/python/cpython/issues/62529
What is the fast way for me read lines from the TCP socket that will work on both Linux and Windows?