Both clients connect to the same address:port. A TCP connection is identified by a pair of address:port, so client1:port1-server:port is a different connection than client2:port2-server:port.
# If you want to accept connections from any network interface
server: LocalPort=>9000, Listen=>SOMAXCONN
# If you want to only accept connections from the local machine
server: LocalHost=>'localhost', LocalPort=>9000, Listen=>SOMAXCONN
client1: PeerAddress=>'server', PeerPort=>9000
client2: PeerAddress=>'server', PeerPort=>9000
Update: Oops, I thought you were asking about PeerPort. The PeerAddress is the DNS name or IP address of the server. The IP address can be obtained from /sbin/ifconfig on linux.
$ /sbin/ifconfig
eth1 Link encap:Ethernet ... # For an Ethernet adapter
inet addr:192.168.3.58 ... # Its IP address
...
lo Link encap:Local Loopback # For machine to contact itself
inet addr:127.0.0.1 # Its IP address
...
Note that 192.168.* is reserved for private networks, which means my machine isn't really on the internet. A NAT gateway links us up. If you want to run a server behind a NAT gateway, outside connectors must connect to the gateway's external address, and the gateway must be setup to forward those connections to your server's machine.
|