Python: Simple Socket Server

The simplest socket server, don’t know why but I always forget how bind is used in python.

import socket
 
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(("127.0.0.1", 1024 + 666))
sock.listen(5)
 
 
client, details = sock.accept()
while 1:
    data = client.recv(1024)
    print "data : %s" % repr(data)