On Tuesday 01 February 2005 03:47, Verdi March wrote:
Hi,
I've a question on socket programming (I'm a bit rusty on this).
I'm reading an article on NAT, which mentions a case where a client opens two sessions (to two distinct remote end-points), but from the same source ip:port.
How is this possible? I thought every time a client program open a socket to a remote ip:port, the OS will automatically associate the local endpoint with a differrent port number? I'm not sure of the context, but, in socket programming, the server "listens" on a known port. (for instance xinetd might listen on port 23 for telnet). When a connection is requested, the server then issues the accept(2) function, and a session is then established. The server can then reissue the listen(2). One of the parameters to listen is the number of backlogged connections. It is the accept(2) function that sets up the TCP connection on the server side. The connect(2) function sets up the request on the client side.
--
Jerry Feldman