1SOCKATMARK(3)              Linux Programmer's Manual             SOCKATMARK(3)
2
3
4

NAME

6       sockatmark - determine whether socket is at out-of-band mark
7

SYNOPSIS

9       #include <sys/socket.h>
10
11       int sockatmark(int sockfd);
12
13   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
14
15       sockatmark(): _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600
16

DESCRIPTION

18       sockatmark()  returns  a  value  indicating  whether  or not the socket
19       referred to by the file descriptor sockfd is at the  out-of-band  mark.
20       If  the socket is at the mark, then 1 is returned; if the socket is not
21       at the mark, 0 is returned.  This function does not remove the  out-of-
22       band mark.
23

RETURN VALUE

25       A  successful  call  to  sockatmark() returns 1 if the socket is at the
26       out-of-band mark, or 0 if it is not.  On  error,  -1  is  returned  and
27       errno is set to indicate the error.
28

ERRORS

30       EBADF  sockfd is not a valid file descriptor.
31
32       EINVAL sockfd  is  not  a  file descriptor to which sockatmark() can be
33              applied.
34

VERSIONS

36       sockatmark() was added to glibc in version 2.2.4.
37

CONFORMING TO

39       POSIX.1-2001.
40

NOTES

42       If sockatmark() returns 1, then the out-of-band data can be read  using
43       the MSG_OOB flag of recv(2).
44
45       Out-of-band data is only supported on some stream socket protocols.
46
47       sockatmark() can safely be called from a handler for the SIGURG signal.
48
49       sockatmark() is implemented using the SIOCATMARK ioctl(2) operation.
50

BUGS

52       Prior to glibc 2.4, sockatmark() did not work.
53

EXAMPLE

55       The following code can be used after receipt of a SIGURG signal to read
56       (and discard) all data up to the mark, and then read the byte  of  data
57       at the mark:
58
59           char buf[BUF_LEN];
60           char oobdata;
61           int atmark, s;
62
63           for (;;) {
64               atmark = sockatmark(sockfd);
65               if (atmark == -1) {
66                   perror("sockatmark");
67                   break;
68               }
69
70               if (atmark)
71                   break;
72
73               s = read(sockfd, buf, BUF_LEN) <= 0);
74               if (s == -1)
75                   perror("read");
76               if (s <= 0)
77                   break;
78           }
79
80           if (atmark == 1) {
81               if (recv(sockfd, &oobdata, 1, MSG_OOB) == -1) {
82                   perror("recv");
83                   ...
84               }
85           }
86

SEE ALSO

88       fcntl(2), recv(2), send(2), tcp(7)
89

COLOPHON

91       This  page  is  part of release 3.25 of the Linux man-pages project.  A
92       description of the project, and information about reporting  bugs,  can
93       be found at http://www.kernel.org/doc/man-pages/.
94
95
96
97Linux                             2008-12-03                     SOCKATMARK(3)
Impressum