Legacy GM Networking system questions

Booyaa

Member
Hello. I am new here, but do not worry. I am not beginner with game maker. I remember old hammer logo. I just did not use yoyogames forum.
I made some not very well working games for my self and only problem is time and graphic. I decided to make some game with networking. First game was disaster as usually. But I learned at least something and I hope second try will be better. It should be "simple" text based "M"MO, better only MO if somebody will play it, but I have some questions about networking and want to ask for best way. I do not want to fail hard again. The system was a mess.
(I have one project for server and one for client, I watched some tutorials.)

First question is about when server receive two buffers at the same time. Can it happen and can server handle it? Will first buffer overwrite the second? I use async_load and received buffer is stored to local variable buffer and then I have a script that reads the buffer. I did not understand if server manage every buffer seperately if they will come in same time and when I am using just local variable.

Second time is about sockets. I used ds_list, but I want to ask about something and it is actually related to first question. I want to send some data back to same client, so I store socket to variable socket_temp that is used later in a code. I want to ask if it is better for client to store socket id to buffer (last information) and then script will read the buffer, find the socket id and send some data back to the same client.

It is simple system, but first question is something I did not understand with networking.
 
N

Nordwin

Guest
Hello and welcome to the forums!

I think you have a problem understanding what a buffer is... A buffer is onlysome kind of storage.. A client has a buffer, which can hold a certain amount of data. If the buffer is full it is transmitted to the server, which also needs a buffer of the same length to store the data. This is only for making communication better. It wouldn't be effective to only transmit one bit after another, because every package needs to know the addresses of the sender and the receiver (like a parcel or a letter you send via mail).
So with this said it now should be clear that one thread of a server can only handle one buffer after another. How many clients your server can handly is depending on the server system specifications and the amount of data which needs to be transmitted for every client.

The server should have a list of clients, who are connected storing each of their socket id's. So it will be redundant to put this information within the buffer. As said above the package already is containing the address. So I don't what you exactly want, but if you want to of course you can store the socket id in a temporaryn variable, rather than accessing the list again.
 

The-any-Key

Member
Can it happen and can server handle it?
It can happen in the same step. You can get multiple messages in the same step. Each after another.
Ex:
This is the normal process:
Step
Step
Step

When using async you can have this:
Step
Async
Async
...
Step
Async
Step
Step
...

Will first buffer overwrite the second?
It will only process one at a time. So that is a no. But remember that the async buffer will be destroyed after the event is done. (When all network async events in your code is done in a step)

I use async_load and received buffer is stored to local variable buffer and then I have a script that reads the buffer.
You must copy the buffer in the async_load. You can not save it to a variable because the buffer will be automatically be destroyed after the async_load event has finished.
 
Last edited:

Booyaa

Member
Nordwin: Thank you. I get it now I think. And it is more clear. So buffers are in a queue and async_load just picking them if I get it right? I am using TCP. So server will handle first buffer then second then third. If lets say 60 buffers will come to server at the same time, the last will have a the biggest delay. It should not be problem, because I will send only results, nothing in real time.

Yea, I have a list. I am using local variable but I am accessing the list twice. For the first time I get id with ds list find index and async_load and then I use ds list find value for socket. It works.

The-any-Key: Well I will hope it will not happen for now.
I save it to local variable but I use it as a argument for a script and save it there. But that was a part of the tutorial. Did not know it is because of it.
 
Last edited:
Top