Home | Sign in | English EN
This content has been translated automatically. Click here to view the French version.
  • Optimizing the connections for an IP address
  • Timeout
  • Connecting to an infrared port
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WindowsLinuxPHPWEBDEV - Browser code
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Stored procedures
Connects a client computer to a given socket.
  • UDP sockets: The UDP protocol being a "connectionless" protocol, SocketConnect cannot be used with the UDP protocol. To send or receive data with the UDP protocol, you must create a UDP socket (SocketCreateUDP) then send/receive data with the "special UDP" syntaxes of SocketWrite and SocketRead.
  • SSL sockets: To send or receive data with the SSL protocol, you must create an SSL socket (SocketCreateSSL) and connect to this socket with SocketConnectSSL.
  • Communication with robots or with non-WINDEV applications: To simplify the exchanges of data by socket, a transmission mode is initialized by default. For a communication with an external module (non-WINDEV application, robot, ...), this transmission mode can prevent the communications from operating properly. SocketChangeTransmissionMode is used to change this transmission mode (the SocketNoEndTag constant allows you not to modify the frames read and written).
Reminder: A socket is a communication resource used by applications to communicate from one computer to another regardless of the type of network.
IF SocketConnect("Server", 8000) = False THEN
Error("Connection error" + ErrorInfo(errMessage))

Connecting to a socket Hide the details

<Result> = SocketConnect(<Socket name> , <Port number> [, <Address> [, <Maximum timeout>]])
<Result>: Boolean
  • True if the function was successful,
  • False otherwise. If an error occurs, you can get the details of the error with ErrorInfo.
<Socket name>: Character string (with quotes)
Name that will be given to the connection opened on the server socket. This name will be used by all socket functions.
<Port number>: entier
Port number of 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 SocketCreate.
<Address>: Optional character string (with quotes)
Address of server. 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 ( for example).
  • URL containing the server name (www.windev.com for example). This syntax is recommended.
<Maximum timeout>: Optional integer or optional Duration
Maximum timeout (in milliseconds) for establishing the connection. This time-out will be used if the server refuses the connection (SocketDeny). In this case, the connection will not be locking. This parameter can correspond to:
  • an integer corresponding to the number of milliseconds,
  • a Duration variable,
  • Versions 23 and later
    the duration in text format (e.g., 1 s or 10 ms).
    New in version 23
    the duration in text format (e.g., 1 s or 10 ms).
    the duration in text format (e.g., 1 s or 10 ms).
This time-out is set to 5000 milliseconds by default (5 seconds). See the remarks for more details.
PHP This parameter is ignored.
Reports and QueriesJavaUser code (UMC)

Optimizing the connections for an IP address

When an IP address is passed to SocketConnect, the connection can be optimized by using the following code:
Socket.Option = SocketOptimizeIPConnection
This option is not enabled by default because Connection may fail in some configurations. However, it may be useful in some applications for which the performances are critical.
Remark: To restore the default operating mode, all you have to do is use the SocketOptionDefault constant:
Socket.Option = SocketOptionDefault


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.
    • the server is not available.
    • the specified address is invalid.
In order to optimize the resolution time of the Address (the search time of the Address), it is recommended:
  • 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 the Socket.Option variable as follows:
    Socket.Option = SocketOptimizeIPConnection
Reports and QueriesUser code (UMC)

Connecting to an infrared port

To connect to a socket that is using an infrared port:
  1. Create a socket using the infrared port on the server (SocketCreateInfrared in a WINDEV application).
  2. In the client application (WINDEV application), use SocketConnectInfrared to connect to this socket.
Component: wd260com.dll
Minimum version required
  • Version 9
This page is also available for…
Does not work on linux, run in a procedure.
04 Jan. 2017