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

Grant Edwards grante at visi.com
Tue Feb 26 14:36:31 EST 2008


On 2008-02-26, Micah Cowan <micah at cowan.name> wrote:

> 7stud, what you seem to be missing, and what I'm not sure if anyone has
> clarified for you (I have only skimmed the thread), is that in TCP,
> connections are uniquely identified by a /pair/ of sockets (where
> "socket" here means an address/port tuple, not a file descriptor).

Using the word "socket" as a name for an address/port tuple is
precisely what's causing all the confusion.  An address/port
tuple is simply not a socket from a python/Unix/C point of
view, and a socket is not an address/port tuple.

> It is fine for many, many connections, using the same local
> port and IP address, so long as the other end has either a
> different IP address _or_ a different port. There is no issue
> with lots of processes sharing the same socket for various
> separate connections, because the /pair/ of sockets is what
> identifies them. See the "Multiplexing" portion of section 1.5
> of the TCP spec (http://www.ietf.org/rfc/rfc0793.txt).

Exactly.

> Reading some of what you've written elsewhere on this thread,
> you seem to be confusing this address/port stuff with what
> accept() returns. This is hardly surprising, as unfortunately,
> both things are called "sockets": the former is called a
> socket in the various RFCs,

I must admit wasn't familiar with that usage (or had forgotten
it).

-- 
Grant Edwards                   grante             Yow! Look DEEP into the
                                  at               OPENINGS!!  Do you see any
                               visi.com            ELVES or EDSELS ... or a
                                                   HIGHBALL?? ...



More information about the Python-list mailing list