Issues with non-blocking raw connection


Symbian Curator

I am having issues with setting up a raw connection, with non-blocking sockets, using Game Maker Studio's built-in functions. Now, this is not a programming question, I know how to program the whole thing, but the issue is the following: The game usually has trouble connecting to a raw server when ran on my computer.

I tried it with a friend over Hamachi, and the game connected without issues and we were able to send data back and forth (in general it worked every time). However, only when the server was hosted on my computer, and when I tried to be the client, the connection would always time out (I'm giving it plenty of time, five to ten seconds).

When I try to host the server on my computer and connect from the same computer, sometimes it works but more often than not it times out again.

I tried it with many different ports, and the results were the same.

However, if I change all functions to regular, non-raw ones, it works. Also, if I change the sockets to blocking ones, it also works.

If it matters, both my friend and me are running Windows 7. The game is compiled with Game Maker: Studio Professional, Early Access v 1.99.493.

Do you know what could be causing this? Is there something about raw connections or non-blocking sockets that I'm missing? (But then again, why does it sometimes work flawlessly?)

Thanks for reading,


I'd suspect that you handled asynchronous connections improperly in your code, such that it would be fast enough for certain connections but too slow for anything less than that. If you never checked for a non-blocking-connected-type Networking event, that's one cue you've done something wrong.


Symbian Curator
I'll provide more info.

This is the code both the server and the client are running at game start:

This is how I set up the server:

while (socket_tcp<0 and port_tcp<65535) {


For the client I create a socket in pretty similar fashion, then try to connect with this:

After that, the server receives a Networking event of type network_type_connect. Here I'm able to get the corresponding socket and the IP of the client.

And finally, the client receives one Networking event of type
network_type_non_blocking_connect. Trouble is, most of the time it just times out, and 10 seconds is more than enough to connect when both the client and the server are on the same machine.


Symbian Curator

Turns out that my code was OK, except for the fact that network_create_socket_ext() simply does not work. I don't know why, but the moment I switched to network_create_socket(), everything started working without any issues (I think that the _ext one reports success even if it fails).