client example [ function: chat]


/ Published in: Python
Save to your folder(s)

http://lineguides.netsons.org


Copy this code and paste it in your HTML
  1. # -*- coding: UTF-8 -*-
  2. import socket
  3.  
  4. def risp():
  5. HOST = '127.0.0.1'
  6. PORT = 90007
  7. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  8. s.connect((HOST, PORT))
  9. text=raw_input('Client::. \t')
  10. if text=='/quit':
  11. print 'BYE'
  12. s.close()
  13. else:
  14. s.send(text)
  15. data = s.recv(1024)
  16. print 'Server::. \t', `data`
  17. s.close()
  18. risp()
  19.  
  20. risp()

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.