ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Communication / Sockets
  • Overview
  • Different modes
  • Modifying the standard behavior of sockets
  • Optimizing the network frames
  • Optimizing the connections for an IP address
  • Re-using an address that is already used
  • Using the default settings
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
Managing sockets with WINDEV, WEBDEV and WINDEV Mobile
Overview
WINDEV, WEBDEV and WINDEV Mobile include several functions allowing you to perform an advanced management of sockets.
A socket is a communication resource used by applications to communicate from one computer to another regardless of the type of network.
This communication mode can be used, for example, to establish a communication between computers connected by Internet.
WINDEV, WEBDEV and WINDEV Mobile allow you to manage:
  • The standard sockets.
  • The UDP sockets.
  • The sockets by infrared.
  • SSL sockets.
Examples for using sockets:
  • manage a messaging in real-time.
  • access to a news server (forum).
Different modes
A WINDEV or WEBDEV application can manage the sockets according to different modes:
Modifying the standard behavior of sockets

Optimizing the network frames

By default, in Windows, the network frames are optimized according to the Nagle algorithm.
To communicate with a system that does not support this optimization (some embedded industrial operating systems for example), this optimization must be disabled.
To do so, enter the following code:
Socket.Option = SocketNagleOff
WINDEVWEBDEV - Server code

Optimizing the connections for an IP address

When an IP address is passed to SocketConnect, you have the ability to optimize the connection 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 performances are critical.

Re-using an address that is already used

By default, SocketCreate allows you to reuse an address (already used by the application itself or by another application). To forbid this operating mode, type the following line of code:
Socket.Option = SocketNoReuseAddress
Remark: By extension, this option allows you to find out whether an address or a port is already used. In this case, SocketCreate returns an error.

Using the default settings

The following code allows you to restore the default setting:
Socket.Option = SocketOptionDefault
Related Examples:
WD Live Messaging Complete examples (WINDEV): WD Live Messaging
[ + ] This example presents the "Socket" functions of WINDEV.
The following topics are presented in this example:
1/ How to connect to a socket
2/ How to create a socket
Summary of the example supplied with WINDEV:
This example present the different functions for socket management supplied with WINDEV. To use this example, a list of contacts must be entered in your address book. The contacts must be identified by a name and the IP address of their computer. When the application is started, the program searches for the accessible contacts (which means the ones who have started this application on their computer). When you double-click a "connected" contact, a discussion window is opened, giving you the ability to communicate with the contact
WD Using sockets Training (WINDEV): WD Using sockets
[ + ] This example presents the use of the "Socket" functions of WINDEV in Client/Server.
The following topics are presented in this example:
1/ How to connect to a socket
2/ How to accept a request for connection
3/ How to write or read on a socket
Summary of the example supplied with WINDEV:
This example presents the different functions for socket management supplied with WINDEV. To use this example, a first instance of the example must be started in "server" mode. Then, by specifying the name of the computer that will be used as server and a nickname, you can connect to this application in "client" mode. You now have the ability to send messages to all the connected users. In this example, a thread and a socket are associated with each connection.
WD Sockets Sample components (WINDEV): WD Sockets
[ + ] This example proposes a component allowing two applications to communicate by using sockets.
WD Trace Socket Sample components (WINDEV): WD Trace Socket
[ + ] The purpose of this example is to trace everything that occurs on a communication via socket, on a specific address, on a specific port. This example allows you to understand the principle of dialog via socket between two applications.
Therefore, in the applications that dialog via socket, even if no trace option as implemented by the developers, you will have he ability to view all the exchanges performed on the socket.
This example also enables you to understand the operating mode of the network protocols based on the sockets: POP3, SMTP, FTP, HTTP, and so on.
Note for the users who are experienced in network communication:
This example does not allow you to trace the UDP packages (only the TCP communications can be traced).
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 06/22/2023

Send a report | Local help