rodrwan

Cliente para servidor con thread

Sep 6th, 2012
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.36 KB | None | 0 0
  1. import socket  
  2.  
  3. s = socket.socket()  
  4. s.connect(("localhost", 9999))  
  5.  
  6. nombre = raw_input("cual es su nick?: ")  
  7. s.send(nombre)
  8.  
  9. while True:  
  10.     mensaje = raw_input(nombre + " >> ")  
  11.     s.send(mensaje)  
  12.     if mensaje == "quit":
  13.         s.send("adios")  
  14.         break
  15.     resp = s.recv(1024)
  16.     print resp
  17.  
  18. print "adios"  
  19.  
  20. s.close()
Advertisement
Add Comment
Please, Sign In to add comment