#!/usr/bin/python import socket my_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) #the first parameter indicates that #the socket is an internet socket #and the second parameter indicates #that it uses TCP HOST = "127.0.0.1" # Loopback interface PORT = 1060 # Sufficiently obscure port # method written by Brandon Rhodes/John Goerzen in Foundations of Python Network Programming def recv_all(sock, length): data = '' while len(data) < length: more = sock.recv(length - len(data)) if not more: raise EOFError('socket closed') data += more return data my_socket.connect((HOST, PORT)) # my_socket.close()