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 fd);
12

DESCRIPTION

14       sockatmark()  returns  a  value  indicating  whether  or not the socket
15       referred to by the file descriptor fd is at the out-of-band  mark.   If
16       the  socket is at the mark, then 1 is returned; if the socket is not at
17       the mark, 0 is returned.  This function does not remove the out-of-band
18       mark.
19

RETURN VALUE

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

ERRORS

26       EBADF  fd is not a valid file descriptor.
27
28       EINVAL fd  is  not  a  file  descriptor  to  which  sockatmark() can be
29              applied.
30

NOTES

32       If sockatmark() returns 1, then the out-of-band data can be read  using
33       the MSG_OOB flag of recv(2).
34
35       Out-of-band data is only supported on some stream socket protocols.
36
37       sockatmark() can safely be called from a handler for the SIGURG signal.
38
39       sockatmark() is implemented using the SIOCATMARK ioctl() operation.
40

CONFORMING TO

42       POSIX.1-2001
43

VERSIONS

45       sockatmark() was added to glibc in version 2.2.4.
46

BUGS

48       Prior to glibc 2.4, sockatmark() did not work.
49

EXAMPLE

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

SEE ALSO

84       fcntl(2), recv(2), send(2), tcp(7)
85
86
87
88Linux                             2006-04-24                     SOCKATMARK(3)
Impressum