]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/sockatmark.3
Wrapped long lines, wrapped at sentence boundaries; stripped trailing
[thirdparty/man-pages.git] / man3 / sockatmark.3
1 .\" Copyright (c) 2006, Michael Kerrisk (mtk-manpages@gmx.net)
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein.
16 .\"
17 .\" Formatted or processed versions of this manual, if unaccompanied by
18 .\" the source, must acknowledge the copyright and authors of this work.
19 .\"
20 .TH SOCKATMARK 3 2006-04-24 "Linux" "Linux Programmer's Manual"
21 .SH NAME
22 sockatmark \- determine whether socket is at out-of-band mark
23 .SH SYNOPSIS
24 .B #include <sys/socket.h>
25 .sp
26 .BI "int sockatmark(int " fd );
27 .SH DESCRIPTION
28 .BR sockatmark ()
29 returns a value indicating whether or not the socket referred
30 to by the file descriptor
31 .I fd
32 is at the out-of-band mark.
33 If the socket is at the mark, then 1 is returned;
34 if the socket is not at the mark, 0 is returned.
35 This function does not remove the out-of-band mark.
36 .SH "RETURN VALUE"
37 A successful call to
38 .BR sockatmark ()
39 returns 1 if the socket is at the out-of-band mark, or 0 if it is not.
40 On error, \-1 is returned and \fIerrno\fP is set to indicate the error.
41 .SH ERRORS
42 .TP
43 .B EBADF
44 .I fd
45 is not a valid file descriptor.
46 .TP
47 .B EINVAL
48 .\" POSIX.1 says ENOTTY for this case
49 .I fd
50 is not a file descriptor to which
51 .BR sockatmark ()
52 can be applied.
53 .SH NOTES
54 If
55 .BR sockatmark ()
56 returns 1, then the out-of-band data can be read using the
57 .B MSG_OOB
58 flag of
59 .BR recv (2).
60
61 Out-of-band data is only supported on some stream socket protocols.
62
63 .BR sockatmark ()
64 can safely be called from a handler for the SIGURG signal.
65
66 .BR sockatmark ()
67 is implemented using the
68 .B SIOCATMARK
69 .BR ioctl ()
70 operation.
71 .SH "CONFORMING TO"
72 POSIX.1-2001
73 .SH VERSIONS
74 .BR sockatmark ()
75 was added to glibc in version 2.2.4.
76 .SH BUGS
77 Prior to glibc 2.4,
78 .BR sockatmark ()
79 did not work.
80 .SH EXAMPLE
81 The following code can be used after receipt of a SIGURG signal
82 to read (and discard) all data up to the mark,
83 and then read the byte of data at the mark:
84 .nf
85
86 char buf[BUF_LEN];
87 char oobdata;
88 int atmark, s;
89
90 for (;;) {
91 atmark = sockatmark(fd);
92 if (atmark == \-1) {
93 perror("sockatmark");
94 break;
95 }
96
97 if (atmark)
98 break;
99
100 s = read(fd, buf, BUF_LEN) <= 0);
101 if (s == -1)
102 perror("read");
103 if (s <= 0)
104 break;
105 }
106
107 if (atmark == 1) {
108 if (recv(fd, &oobdata, 1, MSG_OOB) == \-1) {
109 perror("recv");
110 ...
111 }
112 }
113 .fi
114 .SH "SEE ALSO"
115 .BR fcntl (2),
116 .BR recv (2),
117 .BR send (2),
118 .BR tcp (7)