ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Communication / Sockets
  • Overview
  • The simplified server
  • Step 1: Socket creation
  • Step 2: Data exchange
  • Step 3: Closing the socket
  • Transmission mode of information
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Overview
WINDEV gives you the ability to create a simplified socket server. This server communicates with a single client computer at a time. This type of application is very useful when two remote applications must communicate.
WINDEV Note WINDEV also offers the possibility of creating a more elaborate sockets server (standard sockets server), managing the connection of several client workstations simultaneously. For more details, see Standard socket server.
The simplified server

Step 1: Socket creation

To create the socket, the server uses SocketCreate. A socket is bound to a specific port. To easily use sockets programmatically on the server, specify the socket name.
The client machine will connect to the socket to exchange data. The connection will be actually established at the first data exchange between the two machines (i.e. when the server reads information for the first time).
The connection is established the first time SocketRead reads information on the server successfully.

Step 2: Data exchange

When two machines use the same socket, a communication stream is established between them. These two machines can read from and write character strings to the socket.
Note: To avoid blocking applications, message reception is often managed by a specific thread (for more details on threads, see Thread management).
To read from and write to the socket, the WINDEV server application must use SocketRead and SocketWrite.
Caution: To perform a read, a write must have been performed.. For example:
  1. The client computer writes to the socket: it sends a request to the server.
  2. The server reads data from the socket in a thread. When a message is received, it 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.

Step 3: Closing the socket

To end the communication, the server can close the socket with SocketClose.
Note: the socket can also be closed by the client workstation.
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 of the message is indicated at the beginning of the message.. This transmission mode is recommended when the sockets are used to communicate between two WINDEV applications.
The message looks like this: "11\r\nHelloWorld".
Method 2: standard mode: end of message is signaled by a specific, pre-determined character. 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 is in the form: "Hello World<EOF>".
Method 3: standard mode with buffer: Corresponds to the standard mode optimized for the protocols most commonly used on the Internet.
SocketChangeTransmissionMode allows you to modify the transmission mode used.
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 03/27/2025

Send a report | Local help