Home | Sign in | English EN
  • Overview
  • The simplified server
  • Step 1: Creating the socket
  • Step 2: Exchanging data
  • Step 3: Closing the socket
  • Transmission mode of information
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WindowsLinuxPHPWEBDEV - Browser code
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Stored procedures
WINDEV gives you the ability to create a simplified socket server. This server allows you to communicate with a single client computer at a time. This type of application is very useful when two remote applications must communicate.
WINDEV Remark: WINDEV also allows you to create a more complex socket server (standard socket server), used to manage the connection of several client computers simultaneously. For more details, see Standard socket server.
The simplified server

Step 1: Creating the socket

To create the socket, the server is using SocketCreate. A socket is associated with a specific port. For a simplified use of socket through programming on the server, specify the socket name.
The client computer will connect to this socket in order to exchange data. The connection between the two computers will be actually established during the first exchange of data between the two computers (which means when the server reads information for the first time).
The connection is established during the first successful attempt of SocketRead on the server.

Step 2: Exchanging data

When two computers are using the same socket, a communication stream is established between these two computers. These two computers can read and write character strings on the socket.
Remark: To avoid locking the applications, the management of incoming messages is often performed by a specific thread (for more details, see Managing the threads).
To read and write on the socket, the WINDEV server application must use SocketRead and SocketWrite.
Caution: To perform a read operation, a write operation must have been done beforehand. For example:
  1. The client computer writes into the socket: it sends a request to the server.
  2. The server performs a read operation on the socket in a thread. As soon as a message is received, the message is processed by the server.
  3. If a response to the message is required, the server identifies the client computer (SocketClientInfo) and sends a response to it.

Step 3: Closing the socket

To end the communication, the server can close the socket with SocketClose.
Remark: the socket can also be closed by the client computer.
Transmission mode of information
The transmission mode of the message defines the mode used to specify the length of the message.
Several methods can be used to define the length of message during the communication between sockets.
Method 1: WINDEV mode: By default, the number of characters in the message is specified at the beginning of message. This transmission mode is recommended when the sockets are used to communicate between two WINDEV applications.
The message has the following format: "11\r\nHelloWorld"
Method 2: standard mode: The end of the message is signaled by a specific character, defined in advance. This transmission mode is recommended when the sockets are used to communicate between a WINDEV application and another application. In this case, a specific character must be included in the message to indicate that the message is over.
The message has the following format: "Hello World<EOF>"
Method 3: standard mode with buffer: Corresponds to the standard mode optimized for the most frequently used protocols on Internet.
SocketChangeTransmissionMode allows you to modify the transmission mode used.
Minimum version required
  • Version 9
This page is also available for…
Click [Add] to post a comment