NIO CommKit Host Interface Installation and System Administration Manual

DKMGR(3X) DKMGR(3X)
E-57 CommKit Host Interface, Release 4.0
The server program may also make use of the dk_chk_idle function to see if the device specified by intf and
chan is idle and not in use. This check is made via the common signaling channel and returns zero (EX_OK)
if the channel is idle and EX_UNAVAILABLE if it is not. For obvious reasons, the program should not have
the requested channel open when this check is made. If the circuit is not idle the server can attempt to force
it into the idle state by calling dk_reset_ckt to reset the device, specifying intf and chan. This function also
returns zero (EX_OK) if the request was accepted and EX_UNAVAILABLE if it is not. Both functions will
return EX_OSFILE or EX_NOPERM if there are problems opening or accessing the common signaling
channel. There is no guarantee that the circuit will be returned to the idle state, but it will be rendered unusable
until any processes that have the device open, close(2) it.
EXAMPLE
The code fragments below illustrate how to use dkmgr(3X) routines to create a server, receive and accept
incoming calls.
#include <stdio.h>
#include <dkit/dk.h>
#include <dkit/dkmgr.h>
char cktname[], srvname[];
int child, errcode, fd, infc, retval;
struct mgrmsg *inmsgp;
extern short dk_protocol, recv_win;
.
.
.
while(1) {
inmsgp = dknmgr(srvname, infc);
if ( inmsgp->m_chan <= 0 ) {
error handling;
continue;
}
/* Got an incoming call - validate it */
retval = validate(inmsgp);
if ( retval < 0 ) {
error handling;
continue;
}
child = fork();
if ( child==0 )
/* Child process breaks out of while() loop */
break;
/* Parent stays in while loop to wait for incoming calls */
}
/* This code is executed by the child process */
/* Get the dk circuit device name */
cktname = dk_namer(infc, inmsgp->m_chan);
/*
Check that dk circuit is idle before attempting open.
This call will fail if not executing as ’root’.
*/
retval = dk_chk_idle(infc, inmsgp->m_chan);