Chapter Contents

Previous

Next
Porting UNIX Socket Applications to the SAS/C Environment

INETD and BSD Kernel Routine Dependencies

One of the greatest hurdles to overcome in porting some BSD socket programs is their dependence on BSD kernel routines, such as fork , that are not supported by the SAS/C Compiler (except under USS OS/390). This level of dependency is greatest in BSD daemon programs called from INETD, the UNIX TCP/IP daemon.

Except under USS, SAS/C software does not support the following UNIX kernel routines that are commonly used in TCP/IP daemon processes and other UNIX programs:
fork In the UNIX operating system, the fork system call creates another process with an identical address space. This process enables sockets to be shared between parent and child processes. The fork function is available under USS, and UNIX socket behavior occurs if integrated sockets are specified. However, creating an identical address space this way is not possible under traditional OS/390 or CMS, although the ATTACH macro may be used under OS/390 to achieve similar results.
exec Under UNIX, the exec system call loads a program from an ordinary, executable file onto the current process, replacing the current program. With USS, the exec family of functions may be used to create a process, and the UNIX socket behavior occurs if integrated sockets are specified. Under traditional OS/390 or CMS, the ISO/ANSI C system function sometimes can be used as an alternative to the exec routine, but the semantics and effects are different.
dup , dup2 Unlike UNIX style I/O, standard I/O is the most efficient and lowest level form of I/O under OS/390 and CMS because of the implementation-defined semantics of ISO/ANSI C. The looser semantics place standard I/O closer to native OS/390 and CMS I/O than to UNIX style I/O. The inverted relationship between UNIX style I/O and standard I/O inhibits dup implementation under traditional OS/390 and CMS. However, with USS, dup and dup2 are available, and UNIX socket behavior occurs if integrated sockets are specified.
socketpair , pipe The socket pair and pipe calls are not useful without the fork system call.
Daemons created by INETD depend heavily on the UNIX environment. For example, they assume that a dup call has been issued to correspond to the stdin , stdout , and stderr file pointers. This correspondence relies on the way the fork system call handles file descriptors.

System programs that involve the INETD daemon must be redesigned for OS/390 or CMS. The SAS/C Library provides the givesocket , takesocket , and getclientid functions to allow a socket to be passed between cooperating processes in the absence of the fork system call. Refer to Socket Function Reference for more information on these functions.


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.