GNet conncection problem

BlitzMax Forums/BlitzMax Programming/GNet conncection problem

jsp(Posted 2007) [#1]
I try to connect from a GNET-Client to a GNET-Host.
As i don't know the ip-address i scan the network and try to connect with the normal function:
GNetConnect( host:TGNetHost,address$,port,timeout_ms=10000 )

The problem i face is that every connect even if it failed used a enet_host and after 32 tries all hosts are used and i will never connect to the correct GnetHost if it was not found in the first 32 adresses, because every connect after that will return a false.

When i have a look in the Gnet.bmx file i found:

Method Connect( ip,port,timeout )
If Not _enetHost
_enetHost=enet_host_create( Null,32,0,0 )
If Not _enetHost Return
EndIf
...
Could this not be changed to something like this:

Method Connect( ip,port,timeout )
If Not _enetHost
_enetHost=enet_host_create( Null,32,0,0 )
If Not _enetHost Return
'Start Change
Else
enet_host_destroy(_enetHost)
_enetHost=enet_host_create( Null,32,0,0 )
If Not _enetHost Then Return -1
'End Change
EndIf
...

Don't know if others have already faced the same problem, the change in gnet.bmx works for me but will of course go away with the next sync...
Is this to be considered as a bug or is there something i'm doing wrong?


Blueapples(Posted 2007) [#2]
Well, first I wouldn't recommend just spamming all IP address on your local network. Try using the broadcast address and have your server just listen for a message to reply to...


jsp(Posted 2007) [#3]
Yep, that's right. But i don't spam all addresses. I send out already a broadcast and then check the arp cache who replied, but this can be more than 32 machines.
And if the GNet Host is one of the last... it fails.
What i just not understand is why a failed connection still uses a enet_host?