#!/usr/bin/evn python
# Information Example - Charpter 2 -connect3.py
import socket
print "Creating socket...",
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print "Done."
print "Looking up port number...",
port = socket.getservbyname('http','tcp')
print "Done."
print "Connecting to remote host on port %d..." % port,
s.connect(("www.google.com", port))
print "Done."
print "Connected from", s.getsockname()
print "Connected to", s.getpeername()
This entry was posted on Monday, March 7th, 2016 at 16:26 and is filed under Linux, Python. You can follow any responses to this entry through the RSS 2.0 feed.
Both comments and pings are currently closed.