network_connect

Connect to a GameMaker: Studio server.

Syntax:

GML Code Example

network_connect(socket, url, port);


Argument Description
socket The id of the socket to use.
url The URL or IP to connect to (a string).
port The port to connect to.


Returns: Real


Description

With this function you can send a request to connect to a server. The function takes the socket id to connect through (see network_create_socket) and requires you to give the IP address to connect to (a string) as well as the port to connect through, and if the connection fails a value of less than 0 will be returned. The connection uses a special protocol that ensures only GameMaker: Studio games connect to each other, however if you need to connect to a server that is not a GameMaker: Studio game, you can use network_connect_raw.


Example:

GML Code Example

client = network_create_socket(network_socket_tcp);
 network_connect(client, "192.134.0.1", 6510);
 

The above code will create a new TCP socket then attempt to connect through that to the given IP address on port 6510.





No Examples Submitted

Does this page need better examples? Be the first to Submit

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here