S
Steve Holden
"Routing" traditionally means passing hop-by-hop from one IP address to7stud said:If two sockets are bound to the same host and port on the server, how
does data sent by the client get routed? Can both sockets recv() the
data?
another, but I'll assume that you are actually concerned about delivery
of packets from two separate clients - lets call them (addr1, p1) and
(addrs, p2) - to two server processes both using the same endpoint
address which we will call (addrS, pS). In all cases the first memebr of
the tuple is an IP address and the second is a port number.
Note that the condition I mentioned earlier (with the caveat added by
Roy) ensures that while addr1 and addr2 might be the same, or p1 and p2
might be the same, they can *never* be the same together: if the TCP
layer at addr1 allocates port p1 to one client process, when another
client process asks for an ephemeral port TCP guarantees that it wonn't
be given p1, because that is already logged as in use by another process.
So, in Python terms that represents a guarantee that
(addr1, p1) != (addr2, p2)
and consequently (addr1, p1, addrS, pS) != (addr2, p2, addrS, pS)
Now, when a packet arrives at the server system addressed to the server
endpoint, the TCP layer (whcih maintains a record of *both* endpoints
for each connection) simply looks at the incoming address and port
number to determine which process, of the potentially many using (addrS,
pS), it needs to be delivered to.
If this isn't enough then you should really take this problem to a
TCP/IP group. It's pretty basic, and until you understand it you will
never make sense of TCP/IP client/server communications.
http://holdenweb.com/linuxworld/NetProg.pdf
might help, but I don't guarantee it.
regards
Steve