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.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
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.
I am very proud to read such an informative blog. i Will follow your updates in future so, please add more and more ideas.
ReplyDeletePython Training in Chennai
Python Training in Velachery
Big data training in chennai
JAVA Training in Chennai
SEO training in chennai
Python Training in Chennai
Python Training in Anna Nagar