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
  • Type of message transmission
  • Differences of operating mode between the SocketEndTag and SocketEndTagBuffer constants
  • Message with end tag
  • Transmission between two stations using different string formats (Unicode and ANSI)
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
SocketChangeTransmissionMode (Function)
In french: SocketChangeModeTransmission
Changes the transmission mode used on a socket. This feature is used to define the message encoding during the transmission. SocketRead and SocketWrite are using the specified transmission mode.
Attention: The transmission mode must be identical on the server and client workstations.
Remarks:
  • UDP sockets UDP sockets are always "Socket without Marker" type. SocketChangeTransmissionMode must not be used with the UDP sockets. The UDP protocol is unreliable: the string sent with the SocketWrite function may not arrive or may arrive several times. The strings are not always sent in order.
Reminder A socket is a communication resource used by applications to communicate from one machine to another, regardless of the type of network.
Example
// Mise en place du mode de transmission avec EOF comme marqueur de fin
IF SocketChangeTransmissionMode("Serveur", SocketEndTag) = True THEN
	Info("Mode de transmission modifié")
END
// Mise en place du mode de transmission avec CRLF comme marqueur de fin
IF SocketChangeTransmissionMode(sNomSocket, SocketEndTag, CRLF) = False THEN
	RETURN False
END
Syntax
<Result> = SocketChangeTransmissionMode(<Socket name> , <Type of transmission> [, <Option>])
<Result>: Boolean
  • True if the function was successful,
  • False otherwise (invalid socket name for example). If an error occurs, you can get more details on the error with ErrorInfo.
<Socket name>: Character string
Name of socket defined on the server. This name is defined:
<Type of transmission>: Constant
Type of transmission to use:
SocketEndTagUsed to specify an end tag in <Option>.
A WLanguage error occurs ("End markers not respected") if elements are received after the end marker.
By default, the end tag is the "<EOF>" character string.
Message in the following format: "Hello world<EOF>"
SocketEndTagBufferUsed to specify a buffer end tag in <Option>.
If elements are received after the end marker, the received string is read until the end marker is reached, the remaining part is stored and carried over into the next read operation.
By default, the end tag of the buffer is the "<EOF>" string.
SocketNoEndTagNo tag is added to and/or removed from the transmitted string. In this case, the maximum number of bytes that can be transmitted can be specified with SocketRead.
SocketSizeAtBeginning
(Default value)
This message is a buffer in the following format:
<Length>+CR+<String or buffer to send>

<Length> is an ANSI string corresponding to the length of the string or buffer in bytes.
Example: "9"+CR+"HelloWord".
<Option>: Optional character string or WLanguage constant (CR, CRLF, EOT)
End tag (by default, this marker is the "<EOF>" string).
Remarks

Type of message transmission

The type of message transmission specifies the mode used to define the length of the message.
By default (SocketSizeAtBeginning constant), 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 SocketEndTag and SocketEndTagBuffer constants allow you to use the standard mode for defining the length of messages when communicating by sockets. 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.

Differences of operating mode between the SocketEndTag and SocketEndTagBuffer constants

In both cases, the read operation on the socket waits to receive the end tag.
  • With the constant SocketMarqueurFin If elements are received after the end marker, a WLanguage error is generated, indicating that the end markers are not respected.
  • With the constant SocketMarqueurFinBuffer If elements are received after the end marker, the received string is read up to the end marker, the excess is retained and carried over to the next reading. This allows you to perform partial read operations. This mode simplifies the process of some standard protocols on Internet.
    For example: when connecting to a news server (NNTP protocol), the protocol indicates that the end marker can be "<CRLF>"or ".<CRLF>.<CRLF>". In buffered mode, it's possible to read the first line, and only wait for the second marker if one is required.

Message with end tag

If the encoding of the message takes the end tag into account, there is no need to specify it in the message.

Transmission between two stations using different string formats (Unicode and ANSI)

Some conversions may be required (AnsiToUnicode or UnicodeToAnsi) when messages are transmitted between two computers that use character strings in different formats.
Component: wd300com.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 03/28/2025

Send a report | Local help