HP Rp7410 BSD Sockets Interface Programmer's Guide - Page 83
returns a 0, the next
View all HP Rp7410 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 83 highlights
Advanced Topics for Stream Sockets Sending and Receiving Out-of-band Data 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))