import socket ''' tcp fast open server sample code execute it before enable tfo flag $ echo 3 | sudo tee /proc/sys/net/ipv4/tcp_fastopen ''' PORT = 80 TCP_FASTOPEN = 23 def server(): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.setsockopt(socket.SOL_TCP, TCP_FASTOPEN, 5) s.bind(("", PORT)) s.listen(1024) while True: conn, addr = s.accept() msg = conn.recv(6) print msg conn.send(msg) conn.close() s.close() def main(): server() if __name__ == '__main__': main()