About Me

My photo
Working as Technical Lead in CollabNET software private limited.

Monday 26 October, 2009

Python socket programming

I was in a situation to make the particular port listen,

Below code helped me in doing that simple.

import socket

#create an INET, STREAMing socket
serversocket = socket.socket(
socket.AF_INET, socket.SOCK_STREAM)
#bind the socket to a public host,
# and a well-known port
serversocket.bind((socket.gethostname(), 80))
#become a server socket
serversocket.listen(5)