Legacy GM Networking

M

Métroibè

Guest
Hi. I'm actually working on a multiplayer game on Game maker studio v1.4.

I have seen many video to understand the networking system on game maker but i don't understand some things. I don't understand what is a socket or socket id. I think that it is a way to send or receive data to my clients from my server but i'm not sure. In fact i want to know how to send a message to a certain id of client in my game and not all of the clients at the same time. I don't know how to proccess to connect my clients through the server and do that a certain client receive a message from an other client through the server.

Please, i need help. Thank you.
 

NicoFIDI

Member
the socket it's the conection to the client.
each socket it's a client
to say "I want this player to have this message"
you want to have a relation between the socket and the player.
maybe a dictionary or a object that stores all client information (including socket)
so you can iterate on those objects to do things with players.
it's hard to understand but try to test all the weird things you can and see the result. on server and client.
that's how you can finally get familiar with this server, client, socket, message, structure :)
 
M

Métroibè

Guest
Thank you for all of your help. So, i have tried to create my game without watching any video, just with my knowledges and the game maker book. All of the things that i did, worked fine. But the only problem is that when i want to send a message to my client from the server, i don't know why, the message is sended but the client don't receive this message. I think that it is because i don't know what is the socket id of my server. When i want to send a message to my server from the client i have to use
Code:
 network_send_packet
and set the socket id of my server in the function but for my server i don't know what to do. Actually i replace my socket by my variable wich contain the value of
Code:
 network_create_server_raw(type,port,maxclients);
.

So, my question is : What is the socket id of my server and how can i use this socket id like when i use the socket id of my client ?
 

The-any-Key

Member
When you start the server you create a listening socket. This is just for incoming connections.
When the client try connect to the server the client first create a socket (that give your client socket id, this will be your tube from client to server) and use connect to connect to the server.
When the client try connect to the server. The servers listening socket get the connection request. The async_load["socket"] on the server now hold the socket id from the connected client. This socket id will be the tube from the server to the client.

So the server can now send data to the client with the socket. And the client can send data to the server with the socket.

Note that is is for TCP. UDP got a different life story.

But all of this is explained here:
 
Last edited:
M

Métroibè

Guest
Thank you. I finally succefully created my game. In fact i have tried to do all the game without read or see any tutorial to have a better comprehension of the networking concept. And it's worked verry well. Now i don't have to read a tutorial to make something in my game because i understand the whole things what i do. Now, before writing something i draw all of the steps in a paper and after that, i redo all of the steps in game maker and it work.
 
Top