I have this code using winsock that creates a socket and binds it using the IP of the computer I am
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_DGRAM;
hints.ai_protocol = IPPROTO_UDP;
hints.ai_flags = AI_PASSIVE;
iResult = getaddrinfo(NULL, DEFAULT_PORT, &hints, &result);
if( iResult != 0 ){printf("getaddrinfo failed with error: %d\n", iResult);WSACleanup();return -1;}
for(soketList = result; soketList != NULL; soketList = soketList->ai_next)
{
ConnectSocket = socket(soketList->ai_family, soketList->ai_socktype,soketList->ai_protocol);
if(ConnectSocket == INVALID_SOCKET)
{
printf("socket failed with error: %ld\n", WSAGetLastError());
continue;
}
iResult = bind(ConnectSocket, soketList->ai_addr, soketList->ai_addrlen);
if (iResult == SOCKET_ERROR)
{
printf("bind failed with error: %d\n", WSAGetLastError());
closesocket(ConnectSocket);
continue;
}
break;
}
then I want to see with my own eyes the IP of that socket
InetNtop(soketList->ai_addr->sa_family,soketList->ai_addr->sa_data,(PWSTR)myIP,80)
and the IP is like this... 6354:: not exactly those numbers
Is that IP correct? I was expecting 32 numbers
if I create another application that creates a socket and sends data to that EXACT IP will it work?