Chapter 1. Network Programming Overview

The network programming facilities available with the IRIX operating system include the BSD sockets library, and the Sun Microsystems Remote Procedure Call (RPC) interface, and ISO-OSI's TLI. The programming interface you use depends on the requirements of the application you plan to develop.

This chapter introduces general concepts related to network programming. Topics include:

Introduction to IRIX Network Programming

The BSD program-to-program communication facility provides the socket abstraction. The sockets interface enables low-level access to network addressing and data transfer, and it provides the flexibility to accommodate diverse application requirements. The sockets interface also provides greater speed, simpler programming, and a wider base of platforms than TLI.

RPC implements a remote procedure call model, in which a procedure executing on a remote machine can be treated as a local procedure call by the calling application. RPC enables synchronous execution of procedure calls on remote hosts, provides transparent access to network facilities, and uses eXternal Data Representation (XDR) to ensure portability. (See Chapter 4, “Introduction to RPC Programming”, for more information.)

The International Standards Organization (ISO) has developed a standard known as the Reference Model of Open Systems Interconnection (abbreviated as ISO-OSI, or the OSI Reference Model, or simply OSI). This model conceives of networking as being divided into seven layers. The interface between the fourth and fifth layers (that is, between the transport layer and the session layer) is known as the Transport Layer Interface (TLI); it provides a set of functions for applications to call to perform various network procedures.

Note: Silicon Graphics does not encourage use of the TLI model; its inclusion is for compatibility with interfaces used by other vendors.

The Internet Protocol Suite

A protocol is a set of rules, data formats, and conventions that regulate the transfer of data between participants in the communication.

The IRIX operating system implements the Internet Protocol (IP) suite. The IP suite is a collection of layered protocols developed by the U.S. Department of Defense Advanced Research Projects Agency (DARPA). The two most widely used IP protocols are the Transmission Control Protocol (TCP) and the User Datagram Protocol (UDP).

TCP/IP provides a reliable means of transferring data between systems. TCP/IP messages are acknowledged by the receiver as they are received. UDP/IP provides a faster, low-overhead method of transferring data, but the receiver under UDP/IP does not provide the sender with any acknowledgment of messages received.

TCP creates a virtual circuit, a data path in which data blocks are guaranteed delivery to a target machine in the correct order. Messages are sent from the sender to the receiver until the receiver sends back a message saying that all the data blocks have been received in the correct order.

By using network applications built on top of the IP suite, you can interactively transfer files between computers, log in to remote computers, execute commands on remote computers, and send mail between users on different machines.

Figure 1-1 illustrates the BSD model of network layering.

Figure 1-1. BSD Model of Network Layering

BSD Model of Network Layering

Scheduled Transfers (ST) is a new protocol implemented under a standard being developed in the ANSI T11. committee. ST occupies levels two through four of the OSI networking model. The flow control characteristics of the ST protocol provides the receiving device or host more control over the flow of data. As the name Scheduled Transfers implies, data transfers must be scheduled in advance. ST does not allow data to be sent until the resources to the support the transfer have been allocated and reserved on the receiver.

There a two basic modes of data transmission in ST are as follows:

  • Data sent using the first mode requires resources to be acquired on a per transfer basis.

    This mode requires a three-way handshake prior to the data transmit operation: Request-To-Send Message (RTS), Clear-To-Send Message (CTS), and Data Message (Data).

  • Data sent using the second mode can be written into memory at any time by the sender because it uses the concept of “persistent memory”, in which a region of memory on the receiving device or host has been acquired by the sender ahead of time.

    Because the transmission resources are acquired in advance, this mode does not require a protocol handshake to occur before data is sent.

Compiling BSD and RPC Programs

Most BSD and RPC programs compile and link under IRIX without change. Some BSD and RPC programs, however, may require compiler options, linking with additional libraries, or even source code modification.

Since most BSD and Sun RPC programs were written before the ANSI C standard, you may need to compile with the –cckr command-line option to obtain traditional C semantics. For example:

% cc -cckr example.c -o example 

If your program assumes that the char data type is signed, use the –signed option (most BSD programs assume signed characters, but the IRIX C compiler assumes unsigned characters by default). For example:

% cc -cckr -signed example.c -o example 

The BSD library routines formerly in /usr/lib/libbsd.a (in releases before IRIX 3.3) are now in the standard C library, which is linked in by default during compilation.

Note: In previous versions of IRIX, BSD header files were located in the /usr/include/bsd directory. In more recent versions, such header files are in /usr/include with the other header files. If your program contains #include statements to include header files of the form <bsd/filename.h>, you should remove the bsd/ part of such filenames from the #include statement.

Several network library routines have NIS equivalents that used to be in the libsun library. In current versions of IRIX, libsun has been incorporated into libc.

IRIX provides UNIX System V, BSD, and POSIX signal handling mechanisms. BSD signals are obtained with the –D_BSD_SIGNALS compiler directive.