network programming: how does s.accept() work?
micah at cowan.name
Wed Feb 27 06:10:58 CET 2008
Gabriel Genellina wrote:
> En Tue, 26 Feb 2008 07:53:24 -0200, 7stud <bbxx789_05ss at yahoo.com>
>> 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.
> 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...
More information about the Python-list