DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Programming with the X/Open Transport Interface (XTI)

A read/write interface

A user may want to establish a transport connection and then exec(S) an existing user program such as cat(C) to process the data as it arrives over the connection. However, existing programs use read(S) and write(S) for their input/output needs. The Transport Interface does not directly support a read/write interface to a transport provider, but one is available with UNIX System V. This interface enables a user to issue read and write calls over a transport connection that is in the data transfer phase. This section describes the read/write interface to the connection-mode service of the Transport Interface. This interface is not available with the connectionless-mode service.

The read/write interface is presented using the client example of the ``Connection-mode service'' section with some minor modifications. The clients are identical until the data transfer phase is reached. At that point, this client will use the read/write interface and cat to process incoming data. cat can be run without change over the transport connection. Only the differences between this client and that of the example in the ``Connection-mode service'' section are shown below.

   #include <stropts.h>
   	.
   	.	/*
   	.	 * Same local management and connection
   	.	 * establishment steps.
   	.	 */
   	.
   

if (ioctl(fd, I_PUSH, "tirdwr") < 0) { perror("I_PUSH of tirdwr failed"); exit(5); }

close(0); dup(fd); execl("/usr/bin/cat", "/usr/bin/cat", 0); perror("execl of /usr/bin/cat failed"); exit(6); }

The client invokes the read/write interface by pushing the tirdwr(M) module onto the Stream associated with the transport endpoint where the connection was established (see I_PUSH in streamio(M)). This module converts the Transport Interface above the transport provider into a pure read/write interface. With the module in place, the client calls close(S) and dup(S) to establish the transport endpoint as its standard input file, and uses /usr/bin/cat to process the input. Because the transport endpoint identifier is a file descriptor, the facility for duping the endpoint is available to users.

Because the Transport Interface uses STREAMS, the facilities of this character input/output mechanism can be used to provide enhanced user services. By pushing the tirdwr module above the transport provider, the user's interface is effectively changed. The semantics of read and write must be followed, and message boundaries will not be preserved.


CAUTION: The tirdwr module may only be pushed onto a Stream when the transport endpoint is in the data transfer phase. Once the module is pushed, the user may not call any Transport Interface routines. If a Transport Interface routine is invoked, tirdwr will generate a fatal protocol error, EPROTO, on that Stream, rendering it unusable. Furthermore, if the user pops the tirdwr module off the Stream (see I_POP in streamio(M)), the transport connection will be aborted.

The exact semantics of write, read, and close using tirdwr are described below. To summarize, tirdwr enables a user to send and receive data over a transport connection using read and write. This module will translate all Transport Interface indications into the appropriate actions. The connection can be released with the close system call.


© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005