Socket Python In this post, We learn how to create socket in python programming language. Socket is one endpoint of the two-way communication link between two program running on a network. import socket host = "example.org" port = 80 # Create socket # AF_INET address family # SOCK_STREAM connection protocol socket_object = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # connect to host socket_object.connect((host, port)) # Get peer address socket_object.getpeername() # Get own address socket_object.getsockname() # send data socket_object.sendall('Hello, world') # receive data data = socket_object.recv(1024) # close connection socket_object.close() print 'Received', repr(data) Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.