Posted By

cirio on 05/06/08


Tagged

server chat client


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

mustapha


client example [ function: chat]


 / Published in: Python
 

http://lineguides.netsons.org

  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  

You need to login to post a comment.