NAME | SYNOPSIS | API RESTRICTIONS | DESCRIPTION | RETURN VALUE | ERRORS | ATTRIBUTES | SEE ALSO
$(OS_DIR)/lib/libtelnetd.a #include <arpa/telnetd.h>int telnetdRead(telnetdSessionHandle *hdl, void *buf, unsigned int nchar);
The function or functions documented here may not be used safely in all application contexts with all APIs provided in the ChorusOS 5.0 product.
See API(5FEA) for details.
The telnetdRead() function attempts to read nchar characters from the TELNET session designated by the hdl handle, into the buffer pointed to by buf.
While reading characters from the TELNET connection socket, telnetdRead() filters and executes all TELNET commands sent by the TELNET client. Some of these commands may change the state of the virtual terminal associated with this session (for example, change the client input mode).
The session handle hdl is a pointer to a telnetdSessionHandle data structure which has the following members:
int socket ; /* TELNET connection socket */ int newState ; /* virtual terminal state flag */
where socket is the socket associated with the TELNET session. The newState flag is set to 1 by telnetRead() if the state of the virtual terminal changes during the telnetdRead() operation.
If the TELNET session has no data available and the connection socket has O_NONBLOCK set, telnetdRead() returns -1 and sets errno to EAGAIN. Otherwise, telnetdRead() blocks until data becomes available or the state of the virtual terminal changes.
The O_NONBLOCK option may be set for the connection socket by calling fcntl(2POSIX) after the TELNET session has been initialized using telnetdInit().
On return of telnetdRead() the application should check whether the state of the virtual terminal has changed, and get the new state by calling telnetdGetTermState(). Calling telnetdGetTermState() returns the new terminal state; it also clears the newState flags of the session handle and session descriptor kept internally by the TELNETD library.
On successful completion, telnetdRead() returns the number of characters actually read and placed in the buffer; this number may be less than nchar. Otherwise it returns -1 and sets errno to indicate the error.
The errno file is set to EINVAL if telnetdRead() is called with an invalid hdl handle.
The telnetdRead() function may fail and set errno to any of the errors specified for the read(2POSIX) or write(2POSIX) functions.
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
---|---|
Interface Stability | Evolving |
NAME | SYNOPSIS | API RESTRICTIONS | DESCRIPTION | RETURN VALUE | ERRORS | ATTRIBUTES | SEE ALSO