# InetTelnetWrite

int InetTelnetWrite (int telnetHandle, const char *writeBuffer, char lineTerminatingCharacters[], int bytesToWrite, int *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 | integer | 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.
lineTerminatingCharacters | 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 | integer | 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 | integer | 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 | integer * | 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 | integer | Return value indicating whether the function was successful. A negative number indicates that an error occurred.