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
  • Required permissions
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Run on the server, this function is used to wait for a connection request coming from the client sockets.
Remarks:
  • If the client computer uses a WINDEV application to connect to this socket, the connection request is performed by SocketConnect.
  • UDP-type socket type: The function SocketWaitForConnection function cannot be used with UDP-type sockets.
WEBDEV - Server code To use the sockets on the server, check "Allow server sockets" in the "Advanced" tab of the WEBDEV administrator.
Reminder A socket is a communication resource used by applications to communicate from one machine to another, regardless of the type of network.
Example
WINDEVWEBDEV - Server codeReports and QueriesUser code (UMC)PHPAjax
// Crée un socket sur le poste serveur
IF SocketCreate("Serveur", 8000) = False THEN
	Error("Erreur de création " + ErrorInfo(errMessage))
ELSE
	// Gestion des connexions des postes clients dans un thread
	ThreadExecute("Thread1", threadNormal, ProcédureAttente)
END


INTERNAL PROCEDURE ProcédureAttente()
	IF SocketWaitForConnection("Serveur") THEN
		Canal is string
		// Si la connexion est acceptée, 
		// la gestion de cette connexion est réalisée dans un thread spécifique
		Canal = SocketAccept("Serveur")
		ThreadExecute(Canal, threadNormal, ProcédureGestion, Canal)
	ELSE
		IF NOT SocketExist("Serveur") THEN 
      		  	BREAK
		END
	END
END
Syntax
<Result> = SocketWaitForConnection(<Socket name> [, <Maximum timeout>])
<Result>: Boolean
  • True A new connection request is pending.
  • False no connection request has been detected.
<Socket name>: Character string
Name of the server socket that waits for the connection.
WINDEV Warning: The socket name is "case-sensitive".
<Maximum timeout>: Optional integer or optional Duration
Maximum timeout (in milliseconds).
  • This function is a blocking function during the specified duration or until a connection request is detected.
  • If this parameter is not specified, the function locks the application until the next attempt to connect.
Note if this function is used in a multi-threaded environment, the function only blocks the thread in which it is called.
This parameter can correspond to:
  • an integer representing the number of milliseconds,
  • a Duration variable,
  • the duration in a readable format (e.g., 1 s or 10 ms).
Remarks
AndroidAndroid Widget

Required permissions

This function changes the permissions required by the application.
Required permission: 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: 04/02/2025

Send a report | Local help