Get socket name and peer name : Socket : Network PYTHON TUTORIALS


PYTHON TUTORIALS » Network » Socket »

 

Get socket name and peer name


import socket

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
port = socket.getservbyname('http', 'tcp')
s.connect(("www.google.com", port))
print "Connected from", s.getsockname()
print "Connected to", s.getpeername()



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Network
» Socket