Page 2 of 3

Re: anyone interested in Enet?

Posted: Tue Sep 12, 2023 10:09 pm
by idle
blueb wrote: Tue Sep 12, 2023 2:20 pm Thanks Idle.
I hadn't noticed this before.

My favorite Flight Simulator allows UDP connections, so I now have my work cut out for me. :mrgreen:
See what you can do with it 🙂

Re: anyone interested in Enet?

Posted: Mon Oct 16, 2023 2:04 am
by skinkairewalker
Do you know how to generate the 32bit version of the libraries?

Re: anyone interested in Enet?

Posted: Mon Oct 16, 2023 3:58 am
by idle
If you use cmake gui and mingw it should be able produce both I will look tomorrow if I can

Re: anyone interested in Enet?

Posted: Mon Oct 16, 2023 5:33 am
by skinkairewalker
awesome :D
thanks by u support...


Regarding the maximum 4096 connections, I read something in the documentation that says the enet connection limit is 4095 connections.
So the solution is to create multithreads to create "extra channels".

Re: anyone interested in Enet?

Posted: Mon Oct 16, 2023 10:34 am
by idle
Yes you have upto 4096 connections per Chanel and tou xan have 256 ot them is what I understood.

Re: anyone interested in Enet?

Posted: Tue Oct 17, 2023 7:52 pm
by skinkairewalker
strange, I can't understand this Enet, client events don't even work with c++...
Or am I doing it very wrong xD

debugging the enet_host_service function, I have no return other than 0

Code: Select all

Debug enet_host_service(clients(1)\host, @sevent, 0);
and it seems like you can't reduce the disconnection timeout.

client code:

Code: Select all


XIncludeFile "enetpb.pbi"

Define version 

Structure Client
  *host.ENetHost
  *peer.ENetPeer
EndStructure

Procedure CBPacketDestroy(*packet.ENetPacket) 
  Debug  "free " 
EndProcedure   

Procedure CBpacketCreate(*data,dataLength.i,flags.l);
  Debug "create" 
EndProcedure   

OpenConsole() 

Global CB.ENetCallbacks 

cb\packet_destroy = @CBPacketDestroy() 
cb\packet_create = @CBpacketCreate() 

version = enet_linked_version()
Debug ENET_VERSION_GET_MAJOR(version)
Debug ENET_VERSION_GET_MINOR(version)
Debug ENET_VERSION_GET_PATCH(version)  

If enet_initialize_with_callbacks(version,@cb) = 0  
  
  
  Global *server.ENetHost;
  Global sevent.ENetEvent
  Global Dim clients.client(1)     
  Global address.ENetAddress ;
  Global taddress.ENetAddress; 
  
  
  address\host\h = 0 
  address\host\l = 0  
  
  address\port = 7777; /* Bind the server to port 7777. */
  
    enet_address_set_host_new(@address, "127.0.0.1");
    clients(1)\host = enet_host_create(0, 1, 2, 0, 0);
    clients(1)\peer = enet_host_connect(clients(1)\host, @address, 2, 0);
    If (clients(1)\peer = #Null) 
      PrintN("coundlnt connect");
      End
    EndIf 
 
  
  Repeat 

    Debug enet_host_service(clients(1)\host, @sevent, 0);

  ForEver
  

    enet_peer_disconnect_now(clients(1)\peer,0);
    enet_host_destroy(clients(1)\host)         ;

  enet_deinitialize()
  
EndIf    

Input() 

server code:

Code: Select all


XIncludeFile "enetpb.pbi"

  Define version 

Procedure  host_server(server) 
  
  Protected event.ENetEvent 
  Protected *peer.ENetPeer 
  Protected *address.enetaddress 
  
  Static ct1 
  
  While enet_host_service(server, @event, 1) > 0 
    Select event\type 
      Case #ENET_EVENT_TYPE_CONNECT
        PrintN("A new client connected from " + Str(event\peer\address\port));
        
        enet_peer_set_data(event\peer,ct1);
        ct1+1                
      Case #ENET_EVENT_TYPE_RECEIVE
        PrintN("A packet of length " + Str(event\packet\dataLength)) 
        
      Case #ENET_EVENT_TYPE_DISCONNECT
        PrintN("disconnected " + Str(event\peer\Data));
        
        Debug enet_peer_get_data(event\peer)
        
        
      Case #ENET_EVENT_TYPE_DISCONNECT_TIMEOUT
        PrintN("timeout" + Str(event\peer))
        
        
    EndSelect 
  Wend 
EndProcedure 

Procedure CBPacketDestroy(*packet.ENetPacket) 
  Debug  "free " 
EndProcedure   

Procedure CBpacketCreate(*data,dataLength.i,flags.l);
  Debug "create" 
EndProcedure  

OpenConsole("Enet Server 7777") 

Global CB.ENetCallbacks 

cb\packet_destroy = @CBPacketDestroy() 
cb\packet_create = @CBpacketCreate() 

version = enet_linked_version()
Debug ENET_VERSION_GET_MAJOR(version)
Debug ENET_VERSION_GET_MINOR(version)
Debug ENET_VERSION_GET_PATCH(version)  

If enet_initialize_with_callbacks(version,@cb) = 0  
  
  #MAX_CLIENTS = 4095
  
  Global *server.ENetHost;
  Global sevent.ENetEvent
  Global address.ENetAddress ;
  Global taddress.ENetAddress; 
  
  
  address\host\h = 0 
  address\host\l = 0  
  
  address\port = 7777; /* Bind the server to port 7777. */
  
  server = enet_host_create(@address, #MAX_CLIENTS, 2, 0, 0);
  
   If (server = #Null) 
        MessageRequester("","An error occurred While trying To create an ENet server host.\n");
        End
   EndIf

    PrintN("Started a server...\n");
  
  Repeat 
    host_server(server);
    
  ForEver
  
  host_server(server);
  
  enet_host_destroy(server);
  
  enet_deinitialize()
  
  Input() 
  
EndIf     
  
Do you have any idea of what I'm doing wrong (aside from everything xD) ?

Re: anyone interested in Enet?

Posted: Tue Oct 17, 2023 8:25 pm
by idle
If I recall the time out is 3 seconds so enet should send a heart beat every 1.5 seconds or something like that. Are you getting a connection.
I'm in bed sick with a fever, so won't be coding for a day or two.

Re: anyone interested in Enet?

Posted: Tue Oct 17, 2023 8:53 pm
by skinkairewalker
I'm a little worried... only rest, I'll be here if you need anything!

Re: anyone interested in Enet?

Posted: Tue Oct 17, 2023 9:20 pm
by idle
I'm through the worst, just resting.

Re: anyone interested in Enet?

Posted: Tue Oct 17, 2023 11:05 pm
by skinkairewalker
Sending healing vibes your way.

Re: anyone interested in Enet?

Posted: Thu Nov 23, 2023 3:05 pm
by skinkairewalker
hi, sorry for disappearing..
How are you health?

Re: anyone interested in Enet?

Posted: Thu Nov 23, 2023 6:43 pm
by idle
I'm much better thanks.

Re: anyone interested in Enet?

Posted: Thu Nov 23, 2023 6:50 pm
by Kuron
Very glad to hear it!

Re: anyone interested in Enet?

Posted: Mon Dec 18, 2023 2:24 pm
by skinkairewalker
Knowing that you are ok keeps me motivated!!
Could you help me implement enet as a server for my game currently, or are you too busy?

Re: anyone interested in Enet?

Posted: Mon Dec 18, 2023 7:01 pm
by idle
In the new year I will have time, at the moment it's chaos.