PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Overview
  • The simplified server
  • Step 1: Creating the socket
  • Step 2: Exchanging data
  • Step 3: Closing the socket
  • Transmission mode of information
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Socket: Creating a simplified socket server
Overview
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 between themselves.
WINDEV Note: WinDev also allows you to create a more complex socket server (standard socket server), used to manage the connection of several client computers simultaneously. See Standard socket server for more details.
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. To simplify the use of the socket by programming on the server, specify the name of the socket.
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.
Note: To avoid locking the applications, the management of incoming messages is often performed by a specific thread (see Managing the threads for more details).
To read the socket and write into the socket, the WinDev application server must use SocketRead and SocketWrite.
Caution: To perform a read operation, a write operation must have been performed 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.
Note: 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 the message during the communication between the sockets.
Method 1: WinDev mode: By default, the number of characters in the message is specified at the beginning of the 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 required version
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment