The binding address is the local address for listening; you can specify the address of the local interface.
If you want to control who can connect, you can either check the peer address inside the select / accept loop, or restrict incoming connections using iptables.
Update
If I say serv_addr.sin_addr.s_addr = inet_addr ("192.168.0.1") and the client with the IP address 192.168.0.2 tries to connect, will the command reject it? I want to have multiple threads, each serving a unique IP address.
No, the address is the address on the local computer. Given that you are going to use multi-threaded design, I would recommend that you run the listen / accept code in one thread, check the client address, decide which workflow is suitable, and then start it.
At the risk of showing my age, I still prefer to use listen / accept / select for most socket codes - this is a personal thing of taste and, yes, affects design when it comes to locking / non-blocking IO, buffering, etc.
source share