Advertisement
sotatop

Basic Socket Client

Dec 28th, 2011
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.29 KB | None | 0 0
  1. import socket
  2.  
  3. sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  4. sock.bind(('localhost', 2727))
  5. sock.listen(1)
  6. while True:
  7.     channel, details = sock.accept()
  8.     print "We have recieved a connection with", details
  9.     print channel.recv(100)
  10.     channel.send("Hello.")
  11.     channel.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement