Advertisement
encoree1996

Untitled

Oct 17th, 2015
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. import socket
  2.  
  3. TCP_IP = '127.0.0.1'
  4. TCP_PORT = 1337
  5. BUFFER_SIZE = 1024
  6.  
  7. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  8. s.bind((TCP_IP,TCP_PORT))
  9. s.listen(1)
  10.  
  11. conn, addr = s.accept()
  12. print 'Connection address: ',addr
  13. while 1:
  14. data = conn.recv(BUFFER_SIZE)
  15. if not data: break
  16. print 'received data: {}'.format(data)
  17. conn.send(data[::-1])
  18. conn.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement