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
  • Recreating a socket
  • Re-using an address that is already used
  • Connecting to an infrared port
  • Required permissions
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Create a socket. A socket is a communication resource used by applications to communicate from one computer to another regardless of the type of network.
Remarks:
  • This function must be called on the server used for the communication. If the client computer uses a WINDEV application to connect to this socket, this application will have to use SocketConnect.
  • Sockets SSL: To create an SSL socket, use the SocketCreateSSL function.
  • UDP-type sockets: To create a UDP-type socket, use function SocketCreateUDP.
IF SocketCreate("Serveur", 8000) = False THEN
	Error("erreur création " + ErrorInfo(errMessage))
END
Syntax
<Result> = SocketCreate(<Socket name> , <Port number> [, <Address>])
<Result>: Boolean
  • True if the function was successful,
  • False otherwise. If an error occurs, you can get more details on the error with ErrorInfo.
<Socket name>: Character string
Name that will be given to the socket. This name will be used by all socket functions. Warning: the socket name is "case-sensitive".
<Port number>: Integer
Port number that will be given to the socket. This number must be included between 1 and 65000. This number will be specified when the client computers are connected to the server.
LinuxAndroidAndroid Widget iPhone/iPadIOS WidgetMac Catalyst You must be "root" to create a socket on a port less than or equal to 1024 (being "root" means being the user who has all the permissions on the system).
<Address>: Optional character string
IP address on which the socket must be created on the current computer. If the current computer is associated with several IP addresses (or with several network cards), this parameter enables you to choose the IP address that will be associated with the socket.
This IP address can have the following format:
  • IP address in XXX.XXX.XXX.XXX format (125.5.110.100 for example).
  • IP address containing the name of the server (www.windev.com for example). This syntax is recommended.
WINDEVWEBDEV - Server code The IP address is also returned by NetIPAddress.
Remarks

Recreating a socket

If a socket is not closed properly by SocketClose (restarting the computer for example), recreating the socket may take quite a long time. Indeed, you will have to wait until the socket is freed by the system.
WINDEVWEBDEV - Server codeReports and QueriesiPhone/iPadIOS WidgetMac CatalystJavaUser code (UMC)PHP

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: This option can also be used to determine whether an address or port is already in use.. In this case, SocketCreate returns an error.
WINDEVReports and QueriesUser code (UMC)

Connecting to an infrared port

To connect to a socket that uses 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.
AndroidAndroid Widget

Required permissions

This function changes the permissions required by the application.
Permission required: INTERNET
This permission allows the applications to open the network sockets.
Component: wd300com.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 09/24/2024

Send a report | Local help