With ATM, the CONNECT ACK will come from the most recent switch, and not from the end client. Thus, you will need to call accept () on the socket, and then look at the address (based on the passed addr_family) and just close the socket at this point. By the time he reaches the requester, he is likely to simply be denied.
And I'm not sure how many resources you think it will take, but accepting the connection is very low and that will not be a problem. This is pretty easy to drop.
If you are caught in a DoS attack, your code MAY quit listening mode for a given time, so that an attacker just crashes if you are so worried about it.
Does it really matter if the client knows that the socket is listening? Try using telnet to connect to the local host on port 137 and see how fast file sharing is in Windows ... (If you even turned it on, and if I remembered the correct port number .. heh ..)
But at the SOCKET level, you cannot do what you want. You are talking about going to the TCP layer and looking at the incoming connection requests, and dealing with them.
It can be done, but you are talking about a kernel driver to do this. I'm not sure if you can do this in user mode at all.
If you want Kernel to help with this, let me know. I can give some examples or recommendations.
Only my own two cents, and IMVHO ...
source share