Click to See Complete Forum and Search --> : How to get an IP-String from SOCKADDR_IN


AlionSolutions
January 8th, 2003, 05:39 AM
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

PaulWendt
January 8th, 2003, 06:11 AM
I think this will help you: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/inet_ntoa_2.asp.

Here's Microsoft's Winsock2 function list:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/windows_sockets_functions_2.asp

--Paul

filthy_mcnasty
January 8th, 2003, 05:07 PM
ip = inet_ntoa(si.sin_addr);

AlionSolutions
January 9th, 2003, 12:32 PM
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