SOCKATMARK(3) | Library Functions Manual | SOCKATMARK(3)

# NAME

`sockatmark` — determine whether the read pointer is at the out-of-band data mark

# SYNOPSIS

`#include <sys/socket.h>`

int
`sockatmark`(int s);

# DESCRIPTION

The `sockatmark`() function returns 1 if the read pointer for the socket s is currently at the out-of-band data mark. Otherwise, it returns 0 if the socket doesn't have an out-of-band data mark or if there is normal data to be received before the mark.

# RETURN VALUES

Upon successful completion, the `sockatmark`() function returns the value 1 if the read pointer is pointing at the out-of-band data mark, 0 if it is not. Otherwise the value -1 is returned and the global variable errno is set to indicate the error.

# EXAMPLES

The routine used in the historical remote login process to flush output on receipt of an interrupt or quit signal is shown below. It reads the normal data up to the mark (to discard it), then reads the out-of-band byte.

    #include <sys/socket.h>
    ...
    oob()
    {
    	int mark;
    	char waste[BUFSIZ];

    	for (;;) {
    		if ((mark = sockatmark(rem)) == -1) {
    			perror("sockatmark");
    			break;
    		}
    		if (mark)
    			break;
    		(void) read(rem, waste, sizeof (waste));
    	}
    	if (recv(rem, &mark, 1, MSG_OOB) == -1) {
    		perror("recv");
    		...
    	}
    	...
    }

# ERRORS

The `sockatmark`() call fails if:

[`EBADF`]
  s is not a valid descriptor.
[`ENOTTY`]
  s is valid but does not refer to a socket.

# SEE ALSO

recv(2), send(2)

# STANDARDS

The `sockatmark`() function conforms to IEEE Std 1003.1-2008 (“POSIX.1”).

# HISTORY

The `sockatmark`() function was introduced by IEEE Std 1003.1-2001 (“POSIX.1”) to standardize the historical `SIOCATMARK` ioctl(2). The `sockatmark`() function appeared in OpenBSD 5.7.

The `ENOTTY` error is returned instead of the usual `ENOTSOCK` error to match the historical behavior of `SIOCATMARK`.

June 20, 2019 | Debian