[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:

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

This only returns 127.0.0.1, 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 
out.

 Thanks for helping out,
      -James

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(...,
>"127.0.0.1"). 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.
>
>Lee
>
>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 127.0.0.1, thinking that perhaps 
>>name resolution would find the real IP, but this only returns 127.0.0.1. 
>> 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
>>http://lists.cubik.org/mailman/listinfo/enet-discuss
>>    
>>




More information about the ENet-discuss mailing list