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 <gaf@blu.org> Boston Linux and Unix user group http://www.blu.org PGP key id:C5061EA9 PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9