C++ Winsock API how to get connecting client IP before accepting the connection?

前端 未结 4 961
慢半拍i
慢半拍i 2020-12-21 03:13

I am using the Winsock API (not CAsyncSocket) to make a socket that listens for incoming connections.

When somebody tries to connect, how can I get their IP address

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-21 04:05

    Two reasons why I do not want to accept the connection in order to check the remote IP address:

    1). The client would see that there is a listening socket on this port. If i decide to reject the client connection, I would not want them to know that there is a socket listening on this port.

    2). This technique is not as efficient and requires more CPU, RAM, and network usage; so it is not good in case of a Denial Of Service attack.

提交回复
热议问题