Source

networking / src / echoserver.py

Full commit
#!/usr/bin/env python 

""" 
A simple echo server 
""" 

import socket 

host = '' 
port = 50001 
backlog = 5 
size = 1024 
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 
s.bind((host,port)) 
s.listen(backlog)
 
while True: 
    print '1'
    client, address = s.accept()
    print '2' 
    data = client.recv(size) 
    if data:
        if data == 'bye':
            client.close()
        else:
            client.send(data)