char szHostName[128];
sockaddr_in peer;
LPHOSTENT lpHostEntry;
if( gethostname(szHostName, 128) != 0 )
{
return(FALSE);
}
if ((lpHostEntry = gethostbyname(szHostName)) == NULL)
{
//wsprintf(szPingBuffer, "Could not get %s IP address.",(LPSTR)lpszHostName);
return(FALSE);
}
peer.sin_family=AF_INET;
//peer.sin_addr.s_addr=htonl(INADDR_ANY);
peer.sin_addr=*((LPIN_ADDR) *lpHostEntry->h_addr_list);//这里是你要的IP列表如果你有多个网卡