NIO CommKit Host Interface Installation and System Administration Manual
6-26
Porting CommKit Applications To Release 4.x
Examples
4
5 main()
6{
7 int rtn, fd;
8 struct termio myterm;
9
10 fd=dkdial("nj/shore/vacation");
11 if(fd<0) {
12 printf("dkdial returned %d \n", fd);
13 exit(2);
14 }
15 ioctl(0, TCGETA, &myterm);
16 rtn=dksplice( fd,0);
17
18
19 if(rtn<0) {
20 ioctl(0, I_PUSH, "dkty");
21 ioctl(0, I_PUSH, "ptem”);
22 ioctl(0, I_PUSH, "ldterm”);
23 ioctl(0, TCSETA, &myterm);
24 }
25
26 close(fd);
27 }
28
The following is a description of the dksplice library function example in
Figure 6-7:
• Lines 1 through 3 show the necessary include files.
• Line 10 uses the dkdial function to dial the host to be spliced.
• Line 15 saves the TTY settings of the standard input (file descriptor 0).
• Line 16 splices the call. If the splice works and the user is now connected to the
new machine, the execution drops down to line 26, closes the open file descriptor,
and exits. If the splice fails, the execution enters the recovery code at line 19.
• Lines 20 through 22 push the TTY modules back onto the standard input stream.
• Line 23 resets the terminal modes.
isdkclosed, isdkeof, and isdkleveld Example
Figure 6-8 shows the use of the three level-D query functions, isdkclosed,
isdkeof, and isdkleveld. These functions replace the old DIOCQQABO ioctl
directive, which allowed the caller to find the status of the last read system
call.