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:
#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
.