ADDR = 'localhost', 12345
listener = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
listener.bind(ADDR)
listener.listen(1)
client = socket.create_connection(ADDR)
cf = client.makefile('r+b', bufsize=0)
server, client_addr = listener.accept()
sf = server.makefile('r+b', bufsize=0)
sf.write('Hello World!')
sf.flush()
sf.close()
server.close()
print(cf.read(99))
Can I get a socket.makefile to have the same read semantics as a regular file?