[ENet-discuss] little trouble with enet_address_set_host on Windows

Olivier Delannoy olivier.delannoy at gmail.com
Tue Feb 16 07:48:31 PST 2010


if you want to do a local connection you should try use "localhost" as
your target host I guess.

On Tue, Feb 16, 2010 at 11:13 AM, Benoit Germain <bgermain at ubisoft.fr> wrote:
> Hello,
>
>
>
> I have a little application which contains both a client and a server. The
> client attempts to connect to the server using an address resolved with
> enet_address_set_host to which I give with my PC’s name as shown by ipconfig
> /all. Now, it happens that I also have a video capture device plugged on the
> PC, which for some reason creates a virtual network :
>
>
>
> C:\Documents and Settings\bgermain>ipconfig /all
>
>
>
> Configuration IP de Windows
>
>
>
>         Nom de l'hôte . . . . . . . . . . : ann-bgermain
>
>         Suffixe DNS principal . . . . . . : ubisoft.org
>
>         Type de noud . . . . . . . . . . : Hybride
>
>         Routage IP activé . . . . . . . . : Non
>
>         Proxy WINS activé . . . . . . . . : Non
>
>         Liste de recherche du suffixe DNS : ubisoft.org
>
>
>
> Carte Ethernet Connexion au réseau local 2:
>
>
>
>         Suffixe DNS propre à la connexion :
>
>         Description . . . . . . . . . . . : Broadcom NetXtreme 57xx Gigabit
> Controller
>
>         Adresse IP. . . . . . . . . . . . : 10.2.150.9
>
>
>
> Carte Ethernet Connexion au réseau local 3:
>
>
>
>         Suffixe DNS propre à la connexion :
>
>         Description . . . . . . . . . . . : Connexion TV/vidéo Microsoft
>
>         Adresse physique . . . . . . . . .: 00-00-00-00-00-00
>
>         Autoconfiguration d'adresse IP. . : 0.1.0.4
>
>         Masque de sous-réseau . . . . . . : 255.255.255.255
>
>
>
>
>
>
>
> The problem is that this address comes first in hostEntry, thus causing the
> client to attempt to connect to the video device (I suppose). I have come up
> with a very dirty trick to select the address I am interested in, but maybe
> someone will have a more portable solution ?
>
>
>
> int
>
> enet_address_set_host (ENetAddress * address, const char * name)
>
> {
>
> #if !defined(_XBOX)
>
>     struct hostent * hostEntry;
>
>
>
>     hostEntry = gethostbyname (name);
>
>     if (hostEntry == NULL ||
>
>         hostEntry -> h_addrtype != AF_INET)
>
>     {
>
>         unsigned long host = inet_addr (name);
>
>         if (host == INADDR_NONE)
>
>             return -1;
>
>         address -> host = host;
>
>         return 0;
>
>     }
>
>
>
>     int i = 0;
>
>     for( char *addr = hostEntry -> h_addr_list[i]; addr != NULL; ++ i, addr
> = hostEntry -> h_addr_list[i])
>
>     {
>
>         union UIP
>
>         {
>
>             struct { enet_uint8 a, b, c, d; };
>
>             enet_uint32 asU32;
>
>         };
>
>         UIP ip;
>
>         ip.asU32 = * (enet_uint32 *) addr;
>
>         if( ip.a != 0)
>
>         {
>
>             address -> host = ip.asU32;
>
>             break;
>
>         }
>
>     }
>
> #else
>
>         address -> host = inet_addr(name);
>
> #endif
>
>
>
>     return 0;
>
> }
>
>
>
> _______________________________________________
> ENet-discuss mailing list
> ENet-discuss at cubik.org
> http://lists.cubik.org/mailman/listinfo/enet-discuss
>
>



-- 
Olivier Delannoy
Website: http://olivier.delannoy.dalfy.org/


More information about the ENet-discuss mailing list