ConnectSocket

Description

Creates a socket and attempts to connect to the specified IP address. This will create a TCP connection that you can then use to send and receive data. This command will return immediately and connect in the background, you should use GetSocketConnected to check if the socket connects successfully or fails. You should give a timeout value that is long enough for the socket to connect, typically 3000 milliseconds is a good value, but high latency connections might need longer. If the connection times out then this command will return 0. The port number must match the listening port of the device you are connecting to.

This works slightly differently when exported to HTML5, it uses a WebSocket which sends an HTTP style header and requires an HTTP style response to connect.

Definition

integer ConnectSocket( socketID, szIP, port, timeout )

integer ConnectSocket( szIP, port, timeout )

Parameters