SENDCHAR(3R)

NAME
sendchar, sendnchars - send character(s) to host

SYNOPSIS
int sendchar (c)
char c;

void sendnchars (n, p)
int n;
char *p;

DESCRIPTION
The sendchar function sends a single byte to the host which will normally be read on the standard input of the host process. The bytes sent will be processed as though they were typed on the keyboard by the user.

Since local programs have no host connection, a call to sendchar by a local program will always return -1. Sendchar will always return 1 for non-local programs.

The sendnchars function is similar to sendchar except n characters pointed to by p are sent to the host.

A call to sendchar or sendnchars by an application program causes the bytes to be sent to the host computer to be placed into a buffer in the terminal. The terminal will then send the bytes in the buffer to the host as fast as the communication line to the host is able to transmit. An application program is generally able to queue requests to send bytes to the host much faster than the terminal is able to actually send the bytes over the communication line to the host. So, if an application rapidly sends many bytes to the host, internal terminal buffers eventually fill up. When this happens, the sendchar and sendnchars routines will call wait to block the calling process until internal buffers are no longer full. This whole process is transparent to applications, but application program writers may want to be aware that a call to sendchar or sendnchars may not return immediately.

EXAMPLE
The following program will send a ls command to the host and display its output. Typing a 'q' on the keyboard will cause the program to exit.

    #include <dmd.h>
    main()
    {
    	int c;
    	request(SEND|RCV|KBD);
    	sendnchars(3, "ls\r");
    	do {
    		wait(RCV|KBD);
    		while( (c=rcvchar()) != -1 )
    			lputchar(c);
    	} while(kbdchar() != 'q');
    }

SEE ALSO
local(3R), rcvchar(3R), resources(3R).