[ENet-discuss] Finding host IP

James Turk james at conceptofzero.net
Tue Aug 12 16:42:18 PDT 2003

I think have tried code similar to what you're saying:

cout << convert(addr.host) << endl;  //assume convert is a function that 
converts the uint32 format to a dotted ip.

This only returns, but I'm not sure how to use gethostbyaddr 
nor what the non-winsock equivalent would be,
I can learn to use gethostbyaddr but if there is a similar function I 
can use for Linux builds I'd appreciate that.  As far
as you adding a function to do this to enet, I personally would 
appreciate it, but that's entirely your decision as to if it
would benefit the other users of enet, so I'd understand if you left it 

 Thanks for helping out,

Lee Salzman wrote:

>The closest you can do at this point in time is a reverse lookup
>with enet_address_get_host(), after using enet_address_set_host(...,
>""). To get the interface IP you would need to 
>check the IP list returned by gethostbyaddr(). I can add a function to
>ENet to do this if you'd like.
>On Tue, Aug 12, 2003 at 12:39:50AM -0400, James Turk wrote:
>>Sorry if this has been asked before, I tried searching the list archives 
>>but I may have missed it.  I was wondering, if there is a way in enet to 
>>find the host IP, like on any given computer if there's a way I could 
>>write a function using enet that would work like  char* localIP(); that 
>>would just return the IP in IPv4 format.  Recieving the IP in the 
>>internal uint32 format would work as well as I know how to convert that 
>>back to a.b.c.d.  I've tried setting up a host on the same computer as a 
>>client and connecting to the client as, thinking that perhaps 
>>name resolution would find the real IP, but this only returns 
>> If this isn't built into enet, if anybody else has used this 
>>functionality before and could point me in the right direction to 
>>writing my own outside of enet I'd appreciate the help. 
>>            -James Turk
>>ENet-discuss mailing list
>>ENet-discuss at cubik.org

More information about the ENet-discuss mailing list