Current location - Quotes Website - Team slogan - The problem of obtaining the IP and port of the connecting client through the SOCKET handle!
The problem of obtaining the IP and port of the connecting client through the SOCKET handle!
I haven't seen the problem yet. You can test it.

1. Judge the return value of getpeername, and print out the error code if there is any error;

2. The 2.wsprintf function is aimed at UNICODE characters, right? Why not use sprintf?

3. In your remarks, you said that the correct problem should be the network byte order and the host byte order because the network transmission is low first. Using network byte order on the network is high-order priority. Host byte order actually includes large and small terminals, and functions such as htons, htonl, inet _ addr, inet _ ntoa and inet _ ntol are used to realize the conversion between host byte order and network byte order, and these functions will decide how to convert values into network byte order according to large and small terminals.