<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-text-flowed" style="font-family: -moz-fixed;
font-size: 14px;" lang="x-western">Hello!
<br>
I am using enet library in conjunction with gamespy. I use gamespy
to create socket, connect to lobby, select opponent and do the NAT
punch-through. In next step I close gamespy socket, initialize
enet library and try to create enet host with same port (in my
case I pass ip as empty string) and then start connection to other
party. It works, but not always. I am using three computers right
now: pc vista, pc xp and mac osx 10.7.4. On mac sometimes (not
always) I cannot create enet host (even if i try to create host
with different ports, 100 retries), here's the code:
<br>
<br>
retries = 101;
<br>
enet_address_set_host (&enet.gAddress, ip);
<br>
do {
<br>
enet.gAddress.port = port;
<br>
enet.gHost = enet_host_create (&enet.gAddress , 1 , 2, 0
,0 );
<br>
<br>
if (enet.gHost == NULL)
<br>
{
<br>
printf ( "An error occurred while trying to create an ENet
host(%s:%d).\n",ip,port);
<br>
port++; // HACK
<br>
}
<br>
else
<br>
printf( "host created.\n");
<br>
} while (enet.gHost == NULL && (--retries > 0));
<br>
<br>
Any ideas?
<br>
Thank you!
<br>
Martin
<br>
<br>
</div>
</body>
</html>