Open System Services Programmer's Guide

fprintf(stderr, "READUPDATEX() to %s failed\n", filename);
exit(1);
}
/* Wait for I/O completion on $RECEIVE. */
CC = AWAITIOX(&fnum, /* file number */
, /* buffer address */
&bytesread, /* count transferred */
, /* tag */
IDLE_PERIOD); /* time limit (60 sec) */
/* get last file error ... 6 = sys msg, 40 = timeout */
FILE_GETINFO_(fnum, &error);
if (error != 0 && error != 6 && error != 40)/* if error then exit(1) */
{
fprintf(stderr, "AWAITIOX() to %s failed\n",filename);
exit(0);
}
/* if timeout then exit(0) */
if (error == 40)
{
FILE_CLOSE_(fnum);
printf("Server stopping\n");
exit(0);
}
/* If a system message then handle and reply. */
if (error == 6) /* system message received */
{
switch (msg_buff.sys_msg[0]) /* first short is msg type */
{
case -103: /* open message */
openers++;
break;
case -104: /* close message */
openers--;
break;
default: /* other system message */
break;
}
CC = REPLYX(msg_buff.data, 0); /* reply with 0 data bytes */
if (_status_ne(CC)) /* if error, exit(1) */
{
fprintf(stderr, "REPLYX() to %s failed\n", filename);
exit(1);
}
}
else /* else must be a user request */
{
msg_buff.data[bytesread] = '\0'; /* make string NULL-terminated */
printf("Message received = %s", msg_buff.data);
CC = REPLYX(msg_buff.data, bytesread); /* reply with data */
if (_status_ne(CC)) /* if error, exit(1) */
{
fprintf(stderr, "REPLYX() to %s failed\n", filename);
exit(1);
}
}
} /* end while (!done) */
}
Interprocess-Communication Interoperability 193