• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Destroying a server

D

Drepple

Guest
Hello,

I am working on a project in which people can choose to host or join a server. If a client leaves he gets disconnected fine, but when the host leaves he has to restart the game if he wants to create a new server on the same port. So I assume game maker frees the port when the game is closed, just as how a client gets disconnected when closing the game. Luckily there's a function for a client to disconnect (network_destroy) so they don't have to restart the game. So I was wondering if there's a function for the host to free the port when exiting to the menu so he can create a new server on the same port without restarting. If not it would mean people had to enter ports as well as ip adresses and I want to keep it as simpel as possible.

thanks in advance, Jesse
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
network_destroy is used for both client and server sockets - you would give it the value you've got from network_create_server[_raw].
 
D

Drepple

Guest
Oh, i get it, thanks. Does this send a message to the clients? Like how the server gets a message when someone diconnects?
 
D

Drepple

Guest
network_destroy is used for both client and server sockets - you would give it the value you've got from network_create_server[_raw].
And if so, is it possible to use (async_load[? "type"]) as the client, or does the server has to send a buffer saying he has disconnected?
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
Oh, i get it, thanks. Does this send a message to the clients? Like how the server gets a message when someone diconnects?
It does not - you should send a message and also generally handle timeouts (nothing coming through for >X seconds despite connection remaining to be valid)
 
Top