I'm studing c++ socket programming... The server program binds to a socket and starts listening for connection requests...ok now how can I list the IP addreses of the listened requests? I know I can get the IP addresses after accepting the connections but lets say I don't wanna accept a connection from an specific IP address...
To get the client's public IP address, JavaScript acts as a third-party server-side language. JavaScript can't do it alone, so, jQuery is added to do this. JavaScript works with third-party applications to fetch the IP addresses.
For server IP address, the ServerSocket class uses the IP address of the local network interface through which it received the incoming request. Then, to obtain the remote client IP address, it decodes the IP header of the received TCP packet and uses the source address.
On Windows only, you can use the conditional callback feature of WinSock2's WSAAccept()
function to access client information before accepting a connection, and to even reject the connection before it is accepted.
This can't be done in terms of the standard socket API. On all platforms I know, the system actually accepts the connection (i.e. responds with SYN+ACK TCP datagram) before the application has a chance to monitor the pending request.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With