GML UDP server and client

L

LeXranger

Guest
Hi,

I got some issues to make my game multiplayer.
So I just tried to make a simple server and its not working.. :(
Someone know what I did wrong?

obj_server:
///Initialize our Server.
var type = network_socket_udp;
var port = 25653;
max_clients = 4;

server = network_create_server(type,port,max_clients);
socket = noone;
network_destroy(server);
var type_event = async_load[? "type"];
switch (type_event){
case network_type_connect:
//Add the client to the socket variable - When using multiple clients, use a data structure. This is a single client.
if (socket == noone){ //If No one is connected yet.
socket = async_load[? "socket"];
}
break;

case network_type_disconnect: //If someone tries to disconnect.
socket = noone
break;

case network_type_data: //If we are receiving data

//Handle the data.

break;
}
if (socket == noone){ //If No one is connected yet.
draw_text(100,10,"no one connected")
}else{
draw_text(100,10,"one connected")
}
obj_client:
///Initialize client.
var type = network_socket_udp;
var ip = get_string("Which IP address do you want to connect to?","");
var port = 25653;
socket = network_create_socket(type);
connection = network_connect(socket,ip,port);
///Initialize client.
network_destroy(socket);

Thank you
-LeXranger
 

FrostyCat

Member
The presence of connection- and disconnection-type events in the server and network_connect() in the client suggests that this is TCP-oriented code. Set your type to network_type_tcp. It takes more than just flipping the value of a variable to change TCP-driven code to UDP-driven.
 
L

LeXranger

Guest
The presence of connection- and disconnection-type events in the server and network_connect() in the client suggests that this is TCP-oriented code. Set your type to network_type_tcp. It takes more than just flipping the value of a variable to change TCP-driven code to UDP-driven.
Oh really!? Thank you i'm gonna check that!
 
Top