#!/usr/bin/env python #Basic Connection Example - Chapter 2 - sockets1.py import socket print "\nCreating a socket... ", s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Create socket s( Uses IPv4 , Uses TCP ) print "and I am finished!" print "Looking up port number... ", port = socket.getservbyname('http', 'tcp') # Finds port for ( Port name, Protocol name ) print "Oh I got that!" print "Connecting that socket to a remote host on port %d... " % port, s.connect(("www.google.com", port)) print "and I'm done yet again!\n"