SshWriteLine
BOOL SshWriteLine(
HCLIENT hClient,  
LPCTSTR lpszBuffer,  
LPINT lpnLength  
);

The SshWriteLine function sends a line of text to the remote host, terminated by a carriage-return and linefeed.

Parameters

hClient
Handle to the client session.
lpszBuffer
The pointer to a null-terminated string buffer which contains the data that is to be sent to the remote host. All characters up to, but not including, the terminating null byte will be written to the server. The data will always be terminated with a carriage-return and linefeed control character sequence. If this parameter points to an empty string or NULL pointer, then a only a carriage-return and linefeed are written to the server.
lpnLength
A pointer to an integer value which will contain the number of characters written to the server, including the carriage-return and linefeed sequence. If this information is not required, a NULL pointer may be specified.

Return Value

If the function succeeds, the return value is non-zero. If the function fails, the return value is zero. To get extended error information, call SshGetLastError.

Remarks

The SshWriteLine function writes a line of text to the remote host and terminates the line with a carriage-return and linefeed control character sequence. Unlike the SshWrite function which writes arbitrary bytes of data to the server, this function is specifically designed to write a single line of text data from a null-terminated string.

There are some limitations when using SshWriteLine. The function should only be used to send text, never binary data. In particular, the function will discard nulls and append linefeed and carriage return control characters to the data stream. The Unicode version of this function will accept a Unicode string, however this function does not support sending raw Unicode data to the remote host. Unicode strings will be automatically converted to 8-bit characters using the WideCharToMultiByte function and then written as a stream of bytes.

This function will force the thread to block until the complete line of text has been written, the write operation times out or the remote host aborts the connection. If this function is called with asynchronous events enabled, it will automatically switch the client into a blocking mode, send the data and then restore the client to asynchronous operation. If another network operation is attempted while SshWriteLine is blocked sending data to the remote host, an error will occur. It is recommended that this function only be used with blocking (synchronous) connections; if the application needs to establish multiple simultaneous connections, it should create worker threads to manage each connection.

The SshWrite and SshWriteLine function calls can be safely intermixed.

Unlike the SshWrite function, it is possible for data to have been written to the server if the return value is zero. For example, if a timeout occurs while the function is waiting to send more data to the remote host, it will return zero; however, some data may have already been written prior to the error condition. If this is the case, the lpnLength argument will specify the number of characters actually written up to that point.

Requirements

Client: Requires Windows Vista, Windows XP or Windows 2000 Professional.
Server: Requires Windows Server 2008, Windows Server 2003 or Windows 2000 Server.
Header: Include cstools6.h.
Library: Use cswskav6.lib.
Unicode: Implemented as Unicode and ANSI versions.

See Also

SshIsWritable, SshRead, SshReadLine, SshWrite


Copyright © 2008 Catalyst Development Corporation. All rights reserved.