Method WebSocketClient():connect() Professional

Connects to a websocket server.

Syntax
:connect( [<nConnectMode>] ) --> lSuccess
Parameters
<nConnectMode>
A numerical value which specifies the connection mode. One of the #define constants listed in the following table can be specified for this parameter. The constants are defined in the include file socket.ch.
Connection modes for :connect()
Connection Mode Description
CONNECT_SSL Connect using Secure Socket Layer (SSL) security. This is the default mode for port 443.
CONNECT_PLAIN *) Establish plain text connection.
  1. Default
Return

The logical value true (.T.) when a connection to the server is successfully established, otherwise false (.F.) is returned.

Description

This method establishes a connection to the server. A connection may fail if the server cannot be reached due to an invalid address, firewall issues, or if the server does not respond. The connection also fails when the initial HTTP connection could not be elevated to a websocket connection.

When the connection is successful then the method :onConnect() is executed.

After the client is connected to the server messages can be exchanged. Use the methods :sendText() and :sendBinary() for sending messages to the server. When messages are received from the server then the method :onText() or :onBinary() is executed.

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.