InetTelnetWrite
int InetTelnetWrite (int telnetHandle, const char *writeBuffer, char lineTerminatingCharacter_s[], ssize_t bytesToWrite, ssize_t *bytesWritten, int timeout);
Purpose
Writes bytesToWrite bytes from writeBuffer to the specified Telnet connection. The function returns when it has written bytesToWrite bytes or when timeout ms have elapsed.
Returns 0 if successful or a negative error code otherwise.
![]() |
Note This function does not return timeout as an error. If a timeout occurs, the return value of the function will be 0. Compare bytesToWrite with bytesWritten to detect the timeout condition. If they are not equal, a timeout occurred. |
Parameters
Input | ||
Name | Type | Description |
telnetHandle | int | An integer handle identifying the Telnet connection. You can call InetTelnetOpen to obtain this handle. |
writeBuffer | const char * | The data to write to the Telnet connection. |
lineTerminatingCharacter_s | char [] | Character(s) that will be written to the Telnet connection after writeBuffer has been sent. When you send a command to a remote computer by way of a Telnet server, the command is not processed until you terminate the line (press <Enter>). You must send line–terminating characters that the particular Telnet server understands. National Instruments recommends using the default - carriage return and line feed. |
bytesToWrite | ssize_t | The number of bytes in writeBuffer to be sent over the Telnet connection not including the lineTerminatingCharacters (if any). This value must be less than or equal to the number of bytes in writeBuffer. If writeBuffer is a NUL–terminated string, you do not need to pass in the length, just pass –1. |
timeout | int | Timeout in milliseconds. After timeout ms pass, the function returns without an error. Compare bytesToWrite with bytesWritten after the function returns to detect a timeout. If they are not equal, a timeout occurred. Passing –1 for timeout causes InetTelnetWrite to write indefinitely until it has successfully sent bytesToWrite bytes. |
Output | ||
Name | Type | Description |
bytesWritten | ssize_t | The actual number of bytes successfully written over the Telnet connection not including the lineTerminatingCharacters (if any). If this value is less than bytesToWrite when the function returns, a timeout occurred. Passing NULL for bytesWritten causes this information to be discarded; however, this makes it difficult to determine if the function completed because bytesToRead bytes were read or because a timeout occurred. |
Return Value
Name | Type | Description |
result | int | Return value indicating whether the function was successful. A negative number indicates that an error occurred. |
Additional Information
Library: Internet Library
Include file: cvintwrk.h
LabWindows/CVI compatibility: LabWindows/CVI 7.1 and later
Example
Refer to internet\telnet\telnet.cws for an example of using the InetTelnetWrite function.