• 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.

Network Connections

G

Gomango999

Guest
I have a simple client and server set up going on. The client will attempt to connect to the server in the step event. However, I've found that if the client fails to connect to the server on the first try (e.g. I turn the server program off), it will never be able to connect to the server even when I turn the server program back on. This applies also when I bind the server_connect_raw() function to the space bar. The code for the client is below:

Client Create Event:
Code:
network_set_config(network_config_connect_timeout,1000);
sock = network_create_socket(network_socket_tcp);
server = -1;
send_buff = buffer_create( 256, buffer_grow, 1);
toPrint = ""            //toPrint gets printed out in the draw event in the top left of my screen
Client Step Event:
Code:
if (server < 0) {
    //Try to connect to server
    server = network_connect_raw(sock, "192.168.1.111" , 6510);
    if (server < 0) {
        if (toPrint == "") toPrint = "Connecting";
        toPrint +="."
        if (toPrint == "Connecting.....") toPrint = "Connecting";
    } else toPrint = "Connected!";
}
 
Last edited by a moderator:

The-any-Key

Member
To try connect each step is to ask for trouble.
Try use a timer that try connect every 5 seconds.
Also try destroy the socket and create a new one for the next try.
 
Top