X
XirmiX
Guest
I've been told that I'm too inexperienced to deal with networking... fair enough, but right now I think I'm almost confident enough to make a basic connection between clients and a server, aside from one thing, and that being sockets.
I just need to know how I'm supposed to store them on the server, how to make the server recognise when a socket is being sent by the client (I think?) and how to pick a socket from a list of sockets... For async ds_map, is the "socket" key used to store the entire list for sockets, or is it for something else, because I'm not understanding how this makes sense; if you have a bunch of clients, how is one key, "socket", from ds_map async load, supposed to hold all of the info about them? Or is it not supposed to do that, and instead it's supposed to temporarily hold onto the one who's client you're in the process of checking the socket of?
See what I mean, when I say it confuses me? I was previously to not understand sockets and just assume it's magic, which I'm not buying -.- I'm sure I can make at least SOME form of decent connection if somebody would just explain sockets to me. My current code is a work in progress for networking (on the server side for now, I'm also planning to have two seperate projects for Client and Server, so no sharing of objects or files unless they send buffers to each other through packets!):
Server Create event code
Server Networking event code
I just need to know how I'm supposed to store them on the server, how to make the server recognise when a socket is being sent by the client (I think?) and how to pick a socket from a list of sockets... For async ds_map, is the "socket" key used to store the entire list for sockets, or is it for something else, because I'm not understanding how this makes sense; if you have a bunch of clients, how is one key, "socket", from ds_map async load, supposed to hold all of the info about them? Or is it not supposed to do that, and instead it's supposed to temporarily hold onto the one who's client you're in the process of checking the socket of?
See what I mean, when I say it confuses me? I was previously to not understand sockets and just assume it's magic, which I'm not buying -.- I'm sure I can make at least SOME form of decent connection if somebody would just explain sockets to me. My current code is a work in progress for networking (on the server side for now, I'm also planning to have two seperate projects for Client and Server, so no sharing of objects or files unless they send buffers to each other through packets!):
Server Create event code
Code:
server_trype = network_socket_tcp;
port = 50000;
max_players = 8;
server = network_create_server_raw(server_type, port, max_players);
socket = ds_list_create();
Code:
type = async_load[? "type"];
switch(type)
{
case network_type_connect:
socket_list = async_load[? "socket"];
buffer_seek(buffer, buffer_seek_start, 1);
client_socket_current = buffer_read(buffer, buffer_u8);
player_username = buffer_read(buffer, buffer_u8);
ds_list_add(socket, client_socket_current);
break;
case network_type_disconnect:
socket_list = async_load[? "socket"];
break;
case network_type_data:
break;
}