ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Communication / Sockets
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Establishes an SSL connection between the client and a WebSocket server. Once the connection is established, the WebSocket can be handled like a standard socket, thus allowing you to use SocketRead, SocketWrite, SocketClose or SocketExist.
Remarks:
  • This function has two syntaxes. A synchronous (with a timeout and a return value) and an asynchronous connection syntax (with a callback procedure).
  • With a socket created by the WebSocketClientConnectSSL function, the SocketChangeTransmissionMode function will have no effect. The socket uses the SocketNoEndTag mode.
Example
// On se connecte en mode SYNCHRONE
// au serveur de websocket echo.websocket.events
IF WebSocketClientConnectSSL("wbsocket", "echo.websocket.events") THEN
// Envoie une chaîne au serveur d'echo
IF SocketWrite("wbsocket", "Bonjour le monde!") THEN
// Le serveur d'echo nous retourne la même chaîne
sMsg is string = SocketRead("wbsocket", True)
ToastDisplay("Réponse du serveur: " + sMsg)
END
END
// On se connecte en mode ASYNCHRONE
// au serveur de websocket wss://192.168.100.1/MonProjetServeurWebSocket
WebSocketClientConnectSSL("client", WebSocketClientConnecte_Callback , ...
"192.168.100.1", 443, "MonProjetServeurWebSocket")

INTERNAL PROCÉDURE WebSocketClientConnecte_Callback(nEvénement, sMessage)
SWITCH nEvénement
CASE SocketOpening
SocketWrite("client", "Envoi message depuis le navigateur.")
CASE SocketMessage
Info("Réception d'un message serveur: " + sMessage)
CASE SocketClosing
Info("Fermeture du socket", sMessage)
CASE SocketError
Error("Erreur du socket")
END
END
Syntax

Establish a synchronous SSL connection Hide the details

<Result> = WebSocketClientConnectSSL(<Socket name> , <Server address> [, <Port number> [, <Path> [, <Protocols> [, <SSL option> [, <Maximum timeout>]]]]])
<Result>: Boolean
  • True if the connection was established,
  • False otherwise. If an error occurs, you can get more details on the error with ErrorInfo.
<Socket name>: Character string
Name that will be given to the connection opened on the socket. This name will be used by all socket functions.
<Server address>: Character string
Server address. This address can be given in the following format:
  • IP address in XXX.XXX.XXX.XXX format (125.5.110.100 for example).
  • URL containing the server name (www.windev.com for example). This syntax is recommended.
WINDEVWEBDEV - Server code The address can also correspond to the IP address returned by NetIPAddress.
AndroidAndroid Widget The address must be the server IP address (not the server name).
<Port number>: Optional integer
Port number of the socket. By default, this parameter is 443 (HTTPS port).
<Path>: Optional character string
Path to the virtual directory of the server (if any). By default, or if this parameter is an empty string (""), the path corresponds to "/".
<Protocols>: Optional character string
List of protocols the server must support to establish the connection (for example: "mqtt,soap"). In this list, the different protocols are separated by a comma (","). A (non-exhaustive) list of protocols can be found here: https://www.iana.org/assignments/websocket/websocket.xml
<SSL option>: Optional combination of integer constants
Used to choose the protocol and the identification mode:
ProtocolSSL2SSL2 protocol
LinuxiPhone/iPad This protocol is not supported.
ProtocolSSL3SSL3 protocol
LinuxiPhone/iPad This protocol is not supported.
ProtocolTLS1TLS1 protocol
ProtocolTLS1_1TLS 1.1 protocol
ProtocolTLS1_2TLS 1.2 protocol
ProtocolTLS1_3TLS 1.3 protocol

By default, the combination used is: ProtocolTLS1 + ProtocolTLS1_1 + ProtocoleTLS1_2.
<Maximum timeout>: Optional integer or optional Duration
Maximum timeout (in milliseconds) for establishing the connection. This timeout will be used if the server refuses the connection (SocketDeny). In this case, the connection will not be locking.
This parameter can be:
  • an integer corresponding to the number of milliseconds,
  • a Duration variable,
  • the duration in a readable format (e.g., 1 s or 10 ms).
This wait is equal to 10 milliseconds by default.

Establish an asynchronous SSL connection Hide the details

WebSocketClientConnectSSL(<Socket name> , <WLanguage procedure> , <Server address> [, <Port> [, <Path> [, <Protocols> [, <SSL option>]]]])
<Socket name>: Character string
Name that will be given to the connection opened on the socket. This name will be used by all socket functions.
<WLanguage procedure>: Procedure name
Name of the procedure called when the connection to the server is established. This procedure can be used to send a message to the server with SocketWrite, for example.
For more details on this procedure, see Parameters of the procedure used by WebSocketClientConnectSSL.
CAUTION: the procedure is called in the application's main thread:
  • You can access UI controls from the procedure.
  • The process should not be too long, since this could block the user.
<Server address>: Character string
Server address. This address can be given in the following format:
  • IP address in XXX.XXX.XXX.XXX format (125.5.110.100 for example).
  • URL containing the server name (www.windev.com for example). This syntax is recommended.
WINDEVWEBDEV - Server code The address can also correspond to the IP address returned by NetIPAddress.
AndroidAndroid Widget The address must be the server IP address (not the server name).
<Port>: Optional integer
Port number of the socket. By default, this parameter is 443 (HTTPS port).
<Path>: Optional character string
Path to the virtual directory of the server (if any). By default, or if this parameter is an empty string (""), the path corresponds to "/".
<Protocols>: Optional character string
List of protocols the server must support to establish the connection (for example: "mqtt,soap"). In this list, the different protocols are separated by a comma (","). A (non-exhaustive) list of protocols can be found here: https://www.iana.org/assignments/websocket/websocket.xml
<SSL option>: Optional combination of integer constants
Used to choose the protocol and the identification mode:
ProtocolSSL2SSL2 protocol
LinuxiPhone/iPad This protocol is not supported.
ProtocolSSL3SSL3 protocol
LinuxiPhone/iPad This protocol is not supported.
ProtocolTLS1TLS1 protocol
ProtocolTLS1_1TLS 1.1 protocol
ProtocolTLS1_2TLS 1.2 protocol
ProtocolTLS1_3TLS 1.3 protocol

By default, the combination used is: ProtocolTLS1 + ProtocolTLS1_1 + ProtocoleTLS1_2.
Business / UI classification: Business Logic
Component: wd290com.dll
Minimum version required
  • Version 27
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 09/07/2023

Send a report | Local help