ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Communication / Sockets
  • Optimizing the connections for an IP address
  • Timeout
  • Name resolution
  • Required permissions
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
Used to establish a secure connection to an SSL server.
Example
IF SocketConnectSSL("Server", 8000, "150.134.20") = False THEN
Error("Connection error" + ErrorInfo(errMessage))
END
Syntax
<Result> = SocketConnectSSL(<Socket name> , <Port number> , <Address> [, <SSL option> [, <Maximum timeout> [, <Client certificate>]]])
<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 server socket. This name will be used by all socket functions.
WINDEV Caution: the socket name is case sensitive.
<Port number>: Integer
Port number of the socket. If you are using a socket associated with a preset protocol, use the port number associated with the protocol.
If the socket was created by a WINDEV application, this number must be included between 5 000 and 65 000. In this case, the number must be identical to the port number specified in SocketCreateSSL.
<Address>: Character string
Server address. If this parameter is not specified, the server is sought on the current computer. 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).
<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.
<Client certificate>: Certificate variable
Name of the Certificate variable allowing the server to authenticate the client that wants to connect and to check whether this client is allowed to access the server. This certificate must be recognized on the server.
LinuxAndroidAndroid Widget iPhone/iPad This parameter is not available.
Remarks

Optimizing the connections for an IP address

When an IP address is passed to SocketConnectSSL, the connection can be optimized by using the following code:
Socket.Option = SocketOptimizeIPConnection
This option is not enabled by default because the connection may fail in some configurations. However, it may be useful in some applications for which the performance is critical.
Remark: To restore the default behavior, simply use the SocketOptionDefault constant:
Socket.Option = SocketOptionDefault

Timeout

The timeout specified by <Maximum timeout> groups the timeout of two steps:
  • the timeout for address resolution: this timeout cannot be configured and it can be optimized (see below).
  • the maximum timeout for the connection to be accepted by the server. Several cases may occur:
    • the server refuses the connection.
    • the server accepts the connection within the timeout limit
    • the server is not available.
    • the specified address is invalid.
To optimize the timeout for address resolution (time required to find the address), we advise you to:
  • use a DNS on the network. Therefore, this address will be sought toward this server and not for each computer (1 search instead of x searches where x represents the number of computers). Each computer must be registered toward this server.
  • for an IP address, use Socket.Option = SocketOptimizeIPConnection.
AndroidAndroid Widget

Name resolution

The Android emulator does not use the system of name resolution of the computer on which it is run. This detail is important if your development computer is configured to automatically add a suffix of domain name local to the computer names to resolve. In the Android emulator, the full names must be specified.
For example: If your computer is configured to add the "mydomain.com" suffix to the simple names, the following code:
SocketConnect("myserver")
will attempt to connect to myserver.mydomain.com if it is run directly on the PC and to "myserver" in the Android emulator.
When executed on an Android device, SocketConnectSSL expects an IP address:
SocketConnect("125.5.110.100") // or a string that contains the IP address.
AndroidAndroid Widget

Required permissions

The call to this function modifies the permissions required by the application.
Required permission : INTERNET
This permission allows the applications to open the network sockets.
Business / UI classification: Business Logic
Component: wd300com.dll
Minimum version required
  • Version 12
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 06/21/2023

Send a report | Local help