# InetTelnetReadUntil

int InetTelnetReadUntil (int telnetHandle, char readBuffer[], const char *stringToMatch, int timeout);

## Purpose

Reads from the Telnet connection until stringToMatch is found or timeout ms have elapsed or readBufferLength - 1 bytes have been read. The data is copied into the readBuffer.

Returns 0 if successful or a negative error code otherwise.

| Note This function returns timeout as an error.

## Parameters

Input
Name | Type | Description
telnetHandle | integer | An integer handle identifying the Telnet connection. You can call InetTelnetOpen to obtain this handle.
readBufferLength | const char * | Length of the array passed to the Read Buffer parameter in bytes.
stringToMatch | const char * | When this string is read from the Telnet connection, the function returns. stringToMatch must be a NUL–terminated string.
timeout | integer | Timeout in milliseconds. After timeout ms elapse, the function returns with an error. Passing –1 for timeout causes InetTelnetReadUntil to read indefinitely for stringToMatch.
Output
Name | Type | Description
readBuffer | char [] | The data read from the Telnet connection with the Telnet control characters filtered out. readBuffer must be able to hold all the bytes read through the last byte in the stringToMatch plus one extra byte for the NUL character. Passing NULL for readBuffer causes the function to read for the stringToMatch while discarding the data read.
| Note This function converts any NUL characters received from the Telnet server into line feeds ('\n' or ASCII decimal value 10). This makes readBuffer viewable as a string.

## Return Value

Name | Type | Description
result | integer | Return value indicating whether the function was successful. A negative number indicates that an error occurred.