logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

sockatmark.3p (4661B)


  1. '\" et
  2. .TH SOCKATMARK "3P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. sockatmark
  12. \(em determine whether a socket is at the out-of-band mark
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. #include <sys/socket.h>
  17. .P
  18. int sockatmark(int \fIs\fR);
  19. .fi
  20. .SH DESCRIPTION
  21. The
  22. \fIsockatmark\fR()
  23. function shall determine whether the socket specified by the descriptor
  24. .IR s
  25. is at the out-of-band data mark (see
  26. .IR "Section 2.10.12" ", " "Socket Out-of-Band Data State").
  27. If the protocol for the socket supports out-of-band data by marking the
  28. stream with an out-of-band data mark, the
  29. \fIsockatmark\fR()
  30. function shall return 1 when all data preceding the mark has been read
  31. and the out-of-band data mark is the first element in the receive
  32. queue. The
  33. \fIsockatmark\fR()
  34. function shall not remove the mark from the stream.
  35. .SH "RETURN VALUE"
  36. Upon successful completion, the
  37. \fIsockatmark\fR()
  38. function shall return a value indicating whether the socket is at an
  39. out-of-band data mark. If the protocol has marked the data stream and
  40. all data preceding the mark has been read, the return value shall be 1;
  41. if there is no mark, or if data precedes the mark in the receive queue,
  42. the
  43. \fIsockatmark\fR()
  44. function shall return 0. Otherwise, it shall return a value of \-1
  45. and set
  46. .IR errno
  47. to indicate the error.
  48. .SH ERRORS
  49. The
  50. \fIsockatmark\fR()
  51. function shall fail if:
  52. .TP
  53. .BR EBADF
  54. The
  55. .IR s
  56. argument is not a valid file descriptor.
  57. .TP
  58. .BR ENOTTY
  59. The file associated with the
  60. .IR s
  61. argument is not a socket.
  62. .LP
  63. .IR "The following sections are informative."
  64. .SH EXAMPLES
  65. None.
  66. .SH "APPLICATION USAGE"
  67. The use of this function between receive operations allows an
  68. application to determine which received data precedes the out-of-band
  69. data and which follows the out-of-band data.
  70. .P
  71. There is an inherent race condition in the use of this function. On an
  72. empty receive queue, the current read of the location might well be at
  73. the ``mark'', but the system has no way of knowing that the next data
  74. segment that will arrive from the network will carry the mark, and
  75. \fIsockatmark\fR()
  76. will return false, and the next read operation will silently consume
  77. the mark.
  78. .P
  79. Hence, this function can only be used reliably when the application
  80. already knows that the out-of-band data has been seen by the system or
  81. that it is known that there is data waiting to be read at the socket
  82. (via SIGURG or
  83. \fIselect\fR()).
  84. See
  85. .IR "Section 2.10.11" ", " "Socket Receive Queue",
  86. .IR "Section 2.10.12" ", " "Socket Out-of-Band Data State",
  87. .IR "Section 2.10.14" ", " "Signals",
  88. and
  89. \fIpselect\fR()
  90. for details.
  91. .SH RATIONALE
  92. The
  93. \fIsockatmark\fR()
  94. function replaces the historical SIOCATMARK command to
  95. \fIioctl\fR()
  96. which implemented the same functionality on many implementations. Using
  97. a wrapper function follows the adopted conventions to avoid specifying
  98. commands to the
  99. \fIioctl\fR()
  100. function, other than those now included to support XSI STREAMS. The
  101. \fIsockatmark\fR()
  102. function could be implemented as follows:
  103. .sp
  104. .RS 4
  105. .nf
  106. #include <sys/ioctl.h>
  107. .P
  108. int sockatmark(int s)
  109. {
  110. int val;
  111. if (ioctl(s,SIOCATMARK,&val)==-1)
  112. return(-1);
  113. return(val);
  114. }
  115. .fi
  116. .P
  117. .RE
  118. .P
  119. The use of
  120. .BR [ENOTTY]
  121. to indicate an incorrect descriptor type matches the historical
  122. behavior of SIOCATMARK.
  123. .SH "FUTURE DIRECTIONS"
  124. None.
  125. .SH "SEE ALSO"
  126. .IR "Section 2.10.12" ", " "Socket Out-of-Band Data State",
  127. .IR "\fIpselect\fR\^(\|)",
  128. .IR "\fIrecv\fR\^(\|)",
  129. .IR "\fIrecvmsg\fR\^(\|)"
  130. .P
  131. The Base Definitions volume of POSIX.1\(hy2017,
  132. .IR "\fB<sys_socket.h>\fP"
  133. .\"
  134. .SH COPYRIGHT
  135. Portions of this text are reprinted and reproduced in electronic form
  136. from IEEE Std 1003.1-2017, Standard for Information Technology
  137. -- Portable Operating System Interface (POSIX), The Open Group Base
  138. Specifications Issue 7, 2018 Edition,
  139. Copyright (C) 2018 by the Institute of
  140. Electrical and Electronics Engineers, Inc and The Open Group.
  141. In the event of any discrepancy between this version and the original IEEE and
  142. The Open Group Standard, the original IEEE and The Open Group Standard
  143. is the referee document. The original Standard can be obtained online at
  144. http://www.opengroup.org/unix/online.html .
  145. .PP
  146. Any typographical or formatting errors that appear
  147. in this page are most likely
  148. to have been introduced during the conversion of the source files to
  149. man page format. To report such errors, see
  150. https://www.kernel.org/doc/man-pages/reporting_bugs.html .