Advertisement
rfmonk

socket_modes.py

May 24th, 2014
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.36 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3.  
  4. import socket
  5.  
  6. def test_socket_modes():
  7.         s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  8.         s.setblocking(1)
  9.         s.settimeout(0.5)
  10.         s.bind(("127.0.0.1", 0))
  11.  
  12.         socket_address = s.getsockname()
  13.         print "Trivial Server launched on socket: %s" %str(socket_address)
  14.         while(1):
  15.             s.listen(1)
  16.  
  17. if __name__ == '__main__':
  18.     test_socket_modes()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement