• Hey! Guest! The 39th GMC Jam will take place between November 26th, 12:00 UTC and November 30th, 12:00 UTC. Why not join in! Click here to find out more!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

HTML5 Websocket Glitch? network_connect returns 0 with no server

Wizirdi

Member
SOLVED

Using the following code...

Code:
client = network_create_socket(network_socket_ws);
server = network_connect(client, "192.168.0.1", 64198 );
So basically... network_connect is suppose to return less than zero is no server is running. However, it returns 0 no matter WHAT. Even if there's no server running. I even changed the ip to "asjdhasd" and it still said it connected to that. Lol?

If I switch the socket type to tcp, and run the client with a Windows build it won't connect if the server is running, and connect fine with the server is running.

However, HTML5 will just "connect" no matter what.

What's weird is, when the server is running, the server is seeing it connect... But can not send data back to the client.

Any idea why? I did submit a bug report. But I was wondering if someone had a fix.
 
Last edited:

FrostyCat

Member
There's a related ticket on Mantis that was marked as "fixed" last week: https://bugs.yoyogames.com/view.php?id=31370

It appears you have to handle this using asynchronous sockets instead of network_connect(), so you can't rely on the immediate return value in server for whether it succeeded. In addition, if you're programming the server in another language, you have to treat the traffic as binary. There will be more changes coming in 2.3.
 

Wizirdi

Member
Nevermind. I totally fixed it. It was an issue with the server. I was getting the "id" instead of the "socket" in the async ds_map and trying to send data.... That's embarrassing.

But it's good to know I can't use the info from the network_connect.. That's what was giving me all the confusion, on top of data not sending from the server lol

Thanks!
 
Top