def client(): sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect(('localhost', PORT)) f = sock.makefile(mode="wr") f.write(MSG) f.flush() assert f.readline() == MSG f.close()