[ANet] Restarting server

Posted By: Razoron

[ANet] Restarting server - 10/24/10 12:13

Hi,
currently, I'm working on the server restart function. For that, I deinitialize the compltete server and all clients to reconnect.
But why it isn't possible to recreate a server on the same port:
Code:
#include <acknex.h>
#include "anet.h"


int main()
{
	wait(1);
	
	if(enet_init() == ANET_ERROR)
	{
		error("Couldn't init ANet.");
	}
	
	if(enet_init_server(2700, 10, "") == ANET_ERROR)
	{
		error("Couldn't init first server.");
	}
	
	while(MY_CONNECTION != SERVER_MODE)
	{
		wait(1);
	}
	
	if(enet_init_client("localhost", 2700, "") == ANET_ERROR)
	{
		error("Couldn't init client.");
	}
	
	while(MY_CONNECTION != CLIENT_SERVER_MODE)
	{
		wait(1);
	}
	
	error("All hosts created. Destroying now...");
	
	enet_destroy_host();
	
	while(MY_CONNECTION != NO_CONNECTION)
	{
		wait(1);
	}
	
	if(enet_init_server(2700, 10, "") == ANET_ERROR)
	{
		error("Couldn't init second server.");
	}
}


I can't create the second server, but all hosts are destroyed.
Tell me why laugh.
Posted By: Dark_samurai

Re: [ANet] Restarting server - 10/24/10 21:30

Hi Razoron,

I think I accidently deleted two lines of code when I maintained some stuff in one of the last versions. So the problem is in the ANet source. I've sent you a beta version. Please try it out and tell me if it works now laugh

Thanks for the report!
Posted By: Razoron

Re: [ANet] Restarting server - 10/25/10 12:20

Yep, thanks it works now laugh.
Posted By: Rackscha

Re: [ANet] Restarting server - 10/30/10 17:44

Ah, now that explains why my Bomberman has issues with closing and reconnecting the server, just by updating Anet^^".

Good to read it can be fixed soon.
© 2024 lite-C Forums