Open System Services Programmer's Guide
/* need to post an accept for the next connection */
addrlen = sizeof(addr);
if (accept_nw(fd, (struct sockaddr *)&addr, &addrlen, accept_tag) < 0)
{
printf("accept_nw() call failed [errno %d]\n", errno);
exit(1);
}
}
else /* else data or error on an existing connection */
{
if (bytesread == 0) /* no data - error or close */
{
/* close our end */
FILE_CLOSE_(fd); /* not close(fd)
but FILE_CLOSE_(fd) */
free(msg_buff_ptr[fd]);
msg_buff_ptr[fd] = NULL;
}
else /* data was received */
{
/* so print data and echo it back to sender */
bufferptr[bytesread] = '\0'; /* make string NULL-terminated */
printf("Message received = %s", bufferptr);
if (send_nw(fd, bufferptr, bytesread, 0, send_tag) < 0)
{
printf("send_nw() call failed [errno %d]\n", errno);
exit(1);
}
AWAITIOX(&fd, , , , FOREVER); /* should finish quickly */
/* need to post a recv() for AWAITIOX() to complete */
if (recv_nw(fd, bufferptr, BUFF_LEN, 0, recv_tag) < 0)
{
printf("recv_nw() call failed [errno %d]\n", errno);
exit(1);
}
} /* end else data was received */
}
} /* end while (1) */
}
Using AF_UNIX Sockets
An OSS process can communicate with a Guardian process using AF_UNIX sockets only when
both processes use the OSS sockets APIs because only the OSS sockets APIs support the AF_UNIX
address family.
Systems running RVUs earlier than J06.05 or H06.16 are using AF_UNIX Release 1 sockets and
software.
Systems running J06.05 and later J-series RVUs or H06.16 and later H-series RVUs are using
AF_UNIX Release 2 sockets and software. For AF_UNIX Release 2 software:
• The OSS sockets local server, $ZPLS, is replaced by the OSS local server 2 servers. Although
the name $ZPLS is used as a transport-provider name, $ZPLS is not a process that runs on the
system.
• An OSS local server 2 server $ZLSnn (where nn is the processor number) for each processor
is started automatically when the processor loads.
• Sockets can be created in one of two modes: compatibility mode and portability mode:
Compatibility mode maintains the semantics of AF_UNIX Release 1 sockets to allow
applications to migrate to AF_UNIX Release 2 software without changes.
◦
◦ Portability mode provides behaviors that are similar to other AF_UNIX implementations,
such as Linux and HP-UX.
Interprocess-Communication Interoperability 187