[PLUG] Multiple TCP/IP connections application question

Stafford A. Rau srau at rauhaus.org
Thu Jul 3 08:51:01 UTC 2003


* Matt Alexander <m at pdxlug.org> [030703 08:31]:
> Let's say you have two instances of the same program that are both
> accessing the same remote IP address and service.  When the packets return
> to the OS, how are they redirected to the right program instance?
> 
> For example, if you had several instances of a script that was sending
> different GET/PUT data to a website and returning different results.  How
> are the results matched up with the correct calling program?
> Thanks,
> ~M

A tcp socket is defined by source ip, destination ip, source port, and
destination port.

So in your example, when a client connects to the web site, the client
OS hands the client socket a random, high-numbered ( >1024 ) port to use
as the source port.

Each new client will have a different high-numbered source port, and the
server at the other end will send return data for the given client to
that client's high-numbered port.

--Stafford




More information about the PLUG mailing list