Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get Local IP [C++]
#1
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.
Reply
#2
Better not use this in any multi-threaded apps, people...
Reply
#3
Not to be disrespectful; and thanks for sharing but.
what wat said...
slowly getting better
Reply
#4
I started C++ I might learn this soon.
Reply
#5
thanks man. just started c++ a while ago this.
[Image: icBx9Y.png]
Reply
#6
Looks nice Smile
Will use it once I learn C++ a bit more Smile
Reply
#7
Nice share mate,i may add it in my folder for later use. Thank you.
That's really weird,Ninja
Reply
#8
Oh cool Share. Thanks
Reply
#9
Nice share..
you might want to give credits ;)
Reply
#10
nice share dude Smile
I am new to C++ so this is good to mess around with and learn something Smile
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)