- 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)
In french: SocketChangeModeTransmission
Changes the transmission mode used on a socket. This feature is used to define the message encoding during the transmission. SocketRead
are using the specified transmission mode.
Caution: The transmission mode must be identical on the server and on the client computer.
- 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.
: A socket is a communication resource used by applications to communicate from one computer to another regardless of the type of network.
// Implement the transmission mode with EOF as end marker
IF SocketChangeTransmissionMode("Server", SocketEndTag) = True THEN
Info("Transmission mode modified")
// Implement the transmission mode with CRLF as end marker
IF SocketChangeTransmissionMode(sSocketname, SocketEndTag, CRLF) = False THEN
<Result> = SocketChangeTransmissionMode(<Socket name> , <Type of transmission> [, <Option>])
- 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 was defined:
<Type of transmission>: Constant
Type of transmission to use:
|SocketEndTag||Used 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>"
|SocketEndTagBuffer||Used 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.
|SocketNoEndTag||No 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.|
|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.
<Option>: Optional character string or WLanguage constant (CR, CRLF, EOT)
End tag (by default, this marker is the "<EOF>" string).
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.
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
) when messages are transmitted between two computers that use character strings in different formats.
This page is also available for…