Support Forums

Full Version: Get Local IP [C++]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
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.
Better not use this in any multi-threaded apps, people...
Not to be disrespectful; and thanks for sharing but.
what wat said...
I started C++ I might learn this soon.
thanks man. just started c++ a while ago this.
Looks nice Smile
Will use it once I learn C++ a bit more Smile
Nice share mate,i may add it in my folder for later use. Thank you.
Oh cool Share. Thanks
Nice share..
you might want to give credits ;)
nice share dude Smile
I am new to C++ so this is good to mess around with and learn something Smile
Pages: 1 2