I have it ALMOST working. The results in the debuger shows
Code:
sa_family 2 unsigned short
- sa_data 0x0031276a "" char [14]
[0] 7 '␇' char
[1] 0 char
[2] -84 '¬' char
[3] 19 '␓' char
[4] 8 '␈' char
[5] 112 'p' char
the 19 8 and 112 are correct but the first octet is missing. Do I need to do something special to parse this result?
BTW here is the code for getting your IP address as I have found it to be:
Code:
WORD wVersionRequested;
WSADATA wsaData;
int err;
wVersionRequested = MAKEWORD( 2, 2 );
err = WSAStartup( wVersionRequested, &wsaData );
if ( err != 0 ) {
/* Tell the user that we could not find a usable */
/* WinSock DLL. */
return;
}
char host[255];
char *hostname=&host[0];
memset(hostname,NULL,255);
gethostname(hostname,255);
struct addrinfo *res = NULL;
int rc;
char port='7';
rc = getaddrinfo(hostname,&port,NULL,&res);
if (rc != 0)
fprintf(stderr, "Invalid address %s, getaddrinfo failed: %d\n", hostname, rc);