ADSL dynamic IP problem

zhaozj2021-02-12  134

Q: Our company is connected to the router, by the router dial, I don't know if I can get the dynamic IP of each ADSL dial-up Internet?

A1: Use the reflection. Visit the webpage that can display IP, such as: http: //goboyy.51.net/showip.php Programming to get its content, read the data inside.

A2:

const char * GetOutAddr (SOCKET hSocket, LPCTSTR pszTargetAddr = "www.9cbs.net") {DWORD dwBytesReturned = 0; struct sockaddr_in saTarget; struct sockaddr_in saSource; memset (& saSource, 0, socksize); memset (& saTarget, 0, socksize) ;

saTarget.sin_family = saSource.sin_family = AF_INET; saTarget.sin_addr.s_addr = GetNetAddr (pszTargetAddr); WSAIoctl (hSocket, SIO_ROUTING_INTERFACE_QUERY, (LPVOID) & saTarget, sizeof (sockaddr_in), (LPVOID) & saSource, sizeof (sockaddr_in), & dwBytesReturned, NULL NULL);

Return NTOA (Sasource.SIN_ADDR);

转载请注明原文地址:https://www.9cbs.com/read-7122.html

New Post(0)