08-06-2010, 01:02 AM
Code:
char *GetMyIP()
{
static char ip[16];
SOCKADDR sa;
int sas = sizeof(sa);
memset(&sa, 0, sizeof(sa));
getsockname(sock, &sa, &sas);
sprintf(ip, "%d.%d.%d.%d", (BYTE)sa.sa_data[2], (BYTE)sa.sa_data[3], (BYTE)sa.sa_data[4], (BYTE)sa.sa_data[5]);
return (ip);
}
A Usefull Code I Used in a medi sharing application.