network programming: how does s.accept() work?

Micah Cowan micah at cowan.name
Wed Feb 27 00:10:58 EST 2008


Gabriel Genellina wrote:
> En Tue, 26 Feb 2008 07:53:24 -0200, 7stud <bbxx789_05ss at yahoo.com>
> escribió:
> 
>> ---
>> When you surf the Web, say to http://www.google.com, your Web browser
>> is a client. The program you contact at Google is a server. When a
>> server is run, it sets up business at a certain port, say 80 in the
>> Web case. It then waits for clients to contact it. When a client does
>> so, the server will usually assign a new port, say 56399, specifically
>> for communication with that client, and then resume watching port 80
>> for new requests.
>> ---
>> http://heather.cs.ucdavis.edu/~matloff/Python/PyNet.pdf
> 
> You should *not* trust all you find on the Net...

Didn't give it a thorough read, but I did see a section about the server
setting up a new socket, called a "connection socket".

Which isn't incorrect, but proves Grant's point rather well, that the
confusion is due to the overloaded term "socket". In that context, it's
speaking quite clearly of the "Python/C/Unix" concept of a "socket", and
not (as some other texts do) of the address/port combination.

To reiterate for 7stud, accepting a new "connection socket" does _not_
change the address or port from the originally bound "for-listening" socket.

-- 
Micah J. Cowan
Programmer, musician, typesetting enthusiast, gamer...
http://micah.cowan.name/



More information about the Python-list mailing list