[Tutor] Socket Programming

Joseph Quigley cpu.crazy at gmail.com
Sun Jul 31 05:42:14 CEST 2005

I've got a little problem with my socket program(s):

import socket
#create an INET, STREAMing socket
s = socket.socket(
    socket.AF_INET, socket.SOCK_STREAM)
s.connect(("localhost", 2000))

import socket
#create an INET, STREAMing socket
serversocket = socket.socket(
    socket.AF_INET, socket.SOCK_STREAM)
#bind the socket to a public host,
# and a well-known port
serversocket.bind((socket.gethostname(), 2000))
#become a server socket

while 1:
        #accept connections from outside
        clientsocket, address = serversocket.accept()

I have no idea how to get the server to receive and print a message or 
for the client to send the message. Does anyone know of some good python 
networking tutorials designed for newbies? (Not ones on 
www.awaretek.com. They seem to expect you to know some things that I 
don't even know about.)

    Joe Q.

More information about the Tutor mailing list