sockatmark.3n (2010 09)
s
sockatmark(3N) sockatmark(3N)
NAME
sockatmark() - determine whether a socket is at the out-of-band mark
SYNOPSIS
#include <sys/socket.h>
int sockatmark(int s);
DESCRIPTION
The sockatmark() function determines whether the socket specified by the descriptor
s is at the out-
of-band data mark.
If the protocol for the socket supports out-of-band data by marking the stream with an out-of-band mark,
the
sockatmark() function returns 1 when all data preceding the mark has been read and the out-of-
band mark is the first element in the receive queue. The
sockatmark() function does not remove the
mark from the stream.
X/Open Sockets Only
sockatmark() is new in UNIX 03.
RETURN VALUES
Upon successful completion, the
sockatmark() function returns a value indicating whether the socket
is at an out-of-band data mark:
1 If the protocol has marked the data stream and all data preceding the mark has been read.
0 If there is no mark, or if data precedes the mark in the receive queue.
On failure,
sockatmark() returns -1, and sets errno to indicate the error.
ERRORS
If
sockatmark() fails, errno is set to one of the following values:
[EBADF] The
s argument is not a valid file descriptor.
[ENOTTY] The
s argument does not specify a descriptor for a socket.
APPLICATION USAGE
The use of this function between receive operations allows an application to determine which received
data precedes the out-of-band data and which follows the out-of-band data.
There is an inherent race condition in the use of this function. On an empty receive queue, the current
read of the location might be at the "mark". However, the system has no way of knowing that the next
data segment arriving from the network is carrying the mark. Then sockatmark() returns false, and
the next read operation silently consumes the mark.
Hence, this function can only be used reliably in one or both ways:
• when the application already knows that the out-of-band data has been seen by the system
• and that it knows data is waiting to be read at the socket (by using
SIGURG or select()).
AUTHOR
sockatmark() was developed by HP and IEEE.
SEE ALSO
ioctl(2), pselect(2), recv(2), recvmsg(2), socket(7).
STANDARDS CONFORMANCE
sockatmark(): UNIX 03
HP-UX 11i Version 3: September 2010 − 1 − Hewlett-Packard Company 1