Advertisement
Xenithz

test_socket

Oct 23rd, 2011
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. import socket,time
  2.  
  3.  
  4. connect = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
  5. connect.connect(("127.0.0.1",5555))
  6. connect.settimeout(5)
  7. try:
  8.     print connect.recv(500) # Recieve Welcome Msg
  9.     time.sleep(1)  
  10.     print "Send Hello"
  11.     connect.send("HELLO")  
  12.     print connect.recv(500)  # Must print OLLEH
  13.     time.sleep(1)
  14.     print "Send Python"
  15.     connect.send("python")  
  16.     print connect.recv(500)   # Must print nohtyp
  17.     connect.close()
  18. except socket.timeout:
  19.     print "get Timeout"
  20. print "Send all done"
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement