ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

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 computers that use character strings in different formats (UNICODE and ANSI)
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
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.
Caution: The transmission mode must be identical on the server and on the client computer.
Remarks:
  • WINDEV If a WINDEV application is used on a server and on a client computer, the change of transmission mode must be performed on the client computer and on the server.
  • UDP sockets: The UDP sockets are always "Socket without tag". SocketChangeTransmissionMode must not be used with the UDP sockets. The UDP protocol is an unreliable protocol: the string returned by SocketWrite may not arrive or it 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 computer to another regardless of the type of network.
Example
// Implement the transmission mode with EOF as end marker
IF SocketChangeTransmissionMode("Server", SocketEndTag) = True THEN
Info("Transmission mode modified")
END
// Implement the transmission mode with CRLF as end marker
IF SocketChangeTransmissionMode(sSocketname, SocketEndTag, CRLF) = False THEN
RESULT 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:
WINDEV Caution: the socket name is case sensitive.
<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 SocketEndTag constant: A WLanguage error occurs ("End markers not respected") if elements are received after the end marker.
  • With the SocketEndTagBuffer constant: 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. 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 tag can be "<CRLF>" or "<CRLF>.<CRLF>". With the "buffered" mode, you can read the first line, and wait for the second tag only if one is expected.

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 computers that use character strings in different 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: 06/21/2023

Send a report | Local help