HP Rp3440-4 - 9000 - 0 MB RAM Programmer's Manual page 83

Bsd sockets interface programmer’s guide
Hide thumbs Also See for Rp3440-4 - 9000 - 0 MB RAM:
Table of Contents

Advertisement

out-of-band pointer. However, once you read past the out-of-band pointer
location with subsequent recv calls, the out-of-band byte can no longer
be read.
Usually the out-of-band data message indicates that all data currently in
the stream can be flushed. This involves moving the stream pointer with
successive recv calls, to the location of the out-of-band data pointer.
The request SIOCATMARK informs you, as you receive data from the
stream, when the stream pointer has reached the out-of-band pointer. If
ioctl returns a 0, the next recv provides data sent by the server prior
to transmission of the out-of-band data. ioctl returns a 1 when the
stream pointer reaches the out-of-band byte pointer. The next recv
provides data sent by the server after the out-of-band message. The
following shows how the SIOCATMARK request can be used in a
SIGURG interrupt handler.
/*
s is the socket with urgent data
onurg()
{
int atmark;
char mark;
char flush [100];
while (1) {
/*
** check whether we have read the stream
** up to the OOB mark yet
*/
if (ioctl(s, SIOCATMARK, &atmark) < 0) {
/* if the ioctl failed */
perror("ioctl(SIOCATMARK)");
return;
}
if (atmark) {
/* we have read the stream up to the OOB mark */
break;
}
/*
** read the stream data preceding the mark,
** only to throw it away
*/
if (read(s, flush, sizeof(flush)) <= 0) {
/* if the read failed */
return;
}
}
/*
** receive the OOB byte
*/
recv(s, &mark, 1, MSG_OOB);
Chapter 3
Advanced Topics for Stream Sockets
Sending and Receiving Out-of-band Data
*/
83

Advertisement

Table of Contents
loading

Table of Contents