CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2002
    Location
    Hamburg / Germany
    Posts
    280

    How to get an IP-String from SOCKADDR_IN

    Hi,
    again a relative simple question... but I found no answer:

    I wrote a simple server, which accepts connections as usual. I passed a SOCKADDR_IN-struct to the accept-call to obtain Client-IP, port etc.
    But how to "decrypt" the IP from SOCKADDR_IN.sin_addr ?
    I know that there is a function for "encrypting" an IP-string to an IP-Address. But I have an IP-Address and want a string representation.

    I'm sure somebody can tell me ;o)

    Thanx in advance

    Juergen

  2. #2
    Join Date
    May 2000
    Location
    Phoenix, AZ [USA]
    Posts
    1,347
    I think this will help you: http://msdn.microsoft.com/library/de...net_ntoa_2.asp.

    Here's Microsoft's Winsock2 function list:
    http://msdn.microsoft.com/library/de...unctions_2.asp

    --Paul

  3. #3
    Join Date
    Aug 2002
    Location
    United States
    Posts
    729
    ip = inet_ntoa(si.sin_addr);

  4. #4
    Join Date
    Aug 2002
    Location
    Hamburg / Germany
    Posts
    280

    Thanx

    After sleeping a little, I found myself in a bit confused state about this posting, because I did really ask myself: Oh my god, why did I post this ?
    Stupid me I used that function before. This was in the times before I started using the Borland TSocket-Class.
    Anyway, I think I must organize my work some other way, because I often forget to sleep and eat, and post stupid questions in order ;o)
    Sorry, for posting something useless... wont happen again... I promis ...

    Greetings

    Juergen

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured