Object function reference

connect

A reference entry for connect

Object function · Socket

connect(string hostname, number port) ⇒ boolean

connect(string address, boolean asynchronous = false) ⇒ boolean

Connects to a TCP server at the specified hostname and port. When supplied with a ws:// or wss:// address, it connects to a WebSocket server. The optional asynchronous argument defaults to false; when set to true, the method returns immediately and the on_open, on_message, on_error, and on_close callbacks can be used for lifecycle events. Returns true when the connection is established or the asynchronous connection attempt has started, otherwise false.