Hi,
I'm trying to create a prototype game using enet for networked play.
I am creating the host and client very similarly to what is shown in the 
tutorial, but I cannot get the client to connect to the server.  So far, this 
is all on the same machine...  A client should be able to find a server on the 
same machine, shouldn't it?
I have tried adjusting the port and address settings in many different ways in 
an attempt to make it work but everything fails the same way, e.g. the 
"enet_host_service" call that I make after "enet_host_connet" times out without 
generating any event.
My code is quite large (because I have integrated enet into the existing 
non-networked codebase) but what is done with enet is pretty simple (and even 
simpler during this initial phase...)
The host was created like this:
    ENetAddress address;

    address.host = ENET_HOST_ANY;
    address.port = 1234;
    _data->_enet_host = enet_host_create(
        &address,
        32,
        2,
        0, 0);
and then goes into a loop which calls enet_host_service continually:
        int ret = enet_host_service(_data->_enet_host, &event, 5);

-----

The client was created like this:
    _data->_enet_host = enet_host_create(
        NULL,
        1,
        2,
        0, 0);

    if (!_data->_enet_host)
    {
        ...
    }

    int ret;
    ENetAddress address;
    address.host = ENET_HOST_BROADCAST;
    address.port = _data->_port;

    _data->_enet_peer = enet_host_connect(_data->_enet_host, &address, 1, 0);

    if (_data->_enet_peer == NULL)
    {
        ...
    }

    ENetEvent event;

    ret = enet_host_service(_data->_enet_host, &event, 5000);

    if (ret > 0 && event.type == ENET_EVENT_TYPE_CONNECT)    {        ... <- we 
never get here and "ret" is always zero
    }

-----
I have tried a lot of possibilities for the address and port settings, 
addresses including:
127.0.0.1ENET_HOST_ANY  (host)
ENET_HOST_BROADCAST  (client)
local ip

and various ports such as 55555 or 5432
but nothing seems to work.  I am compiling for x64 on windows using VC2017.  
Enet is running in its own thread, and I have been careful with a 
critical_section for the parts that need it, but the program is not getting far 
enough to reach any thread<->thread issues yet...  
My problem is I don't know where the problem might lie:
1) can Enet work on a single machine?2) can ENET_HOST_BROADCAST work on a 
single machine?3) can it be network settings / firewall (I doubt this since in 
the past I have done a lot of general client server work from VMs hosted on 
this same machine without any difficulty...)
I basically need some hint on where to look for the problem...  Does Enet have 
some sort of verbose mode that will log problems to the debug stream?
Thanks for any help, I did try looking in the mail-list archives but my problem 
is not really knowing what to search for...
Later I will try again at home, which should eliminate network/firewalls as a 
possibility...
Thanks again,
Ian



_______________________________________________
ENet-discuss mailing list
ENet-discuss@cubik.org
http://lists.cubik.org/mailman/listinfo/enet-discuss

Reply via email to