SOCKATMARK(3POSIX)
π SOCKATMARK β the sockatmark() page, but make it make sense π
okay so bestie, real talk before we start: this page is from the POSIX Programmer's Manual β it's sockatmark(3POSIX). The Linux version of this interface might behave differently (so go peek at the matching Linux man page for the tea β), or honestly it might not even be implemented on Linux at all. π
β¨ PROLOG β¨
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ β consult the corresponding Linux manual page for details of Linux behavior β or the interface may not be implemented on Linux. (no cap, check first before you build your whole personality around it)
πΈ NAME πΈ
sockatmark β determine whether a socket is at the out-of-band mark
yes queen, it's a yes/no girlie. she just tells you if you're sitting right on the mark or not. π
π SYNOPSIS π
#include <sys/socket.h>
int sockatmark(int s);
π¦ DESCRIPTION π¦
The sockatmark() function shall determine whether the socket specified by the descriptor s is at the out-of-band data mark (see Section 2.10.12, Socket Out-of-Band Data State).
So here's the vibe: if the protocol for the socket supports out-of-band data by marking the stream with an out-of-band data mark, then sockatmark() shall return 1 when all data preceding the mark has been read and the out-of-band data mark is the first element in the receive queue.
And the icon behaviour? The sockatmark() function shall not remove the mark from the stream. She looks, she does not touch. respectful. π«Ά
π RETURN VALUE π
Upon successful completion, the sockatmark() function shall return a value indicating whether the socket is at an out-of-band data mark.
- If the protocol has marked the data stream and all data preceding the mark has been read β the return value shall be
1β¨ - If there is no mark, or if data precedes the mark in the receive queue β
sockatmark()shall return0πΆ - Otherwise β it shall return a value of
-1and seterrnoto indicate the error. it's giving error era, bestie
π₯ ERRORS π₯
The sockatmark() function shall fail if:
EBADFβ Thesargument is not a valid file descriptor. (she literally does not know her)ENOTTYβ The file associated with thesargument is not a socket. ma'am, that is not a socket, that is a whole other thing
The following sections are informative.
π EXAMPLES π
None.
literally nothing. empty. the void. π</purl>
π§ APPLICATION USAGE π§
The use of this function between receive operations allows an application to determine which received data precedes the out-of-band data and which follows the out-of-band data. so useful, so precise, chef's kiss
β οΈ There is an inherent race condition in the use of this function. On an empty receive queue, the current read of the location might well be at themark, but the system has no way of knowing that the next data segment that will arrive from the network will carry the mark, andsockatmark()will return false, and the next read operation will silently consume the mark. π
yeah. silent. consuming. the mark. the audacity.
Hence, this function can only be used reliably when the application already knows that the out-of-band data has been seen by the system, or that it is known that there is data waiting to be read at the socket β via SIGURG or select().
See Section 2.10.11, Socket Receive Queue, Section 2.10.12, Socket Out-of-Band Data State, Section 2.10.14, Signals, and pselect() for details.
π RATIONALE π
The sockatmark() function replaces the historical SIOCATMARK command to ioctl(), which implemented the same functionality on many implementations. Using a wrapper function follows the adopted conventions to avoid specifying commands to the ioctl() function β other than those now included to support XSI STREAMS. glow up era, we're wrapping things now
The sockatmark() function could be implemented as follows:
#include <sys/ioctl.h>
int sockatmark(int s)
{
int val;
if (ioctl(s,SIOCATMARK,&val)==-1)
return(-1);
return(val);
}
The use of [ENOTTY] to indicate an incorrect descriptor type matches the historical behavior of SIOCATMARK.
β FUTURE DIRECTIONS β
None.
π SEE ALSO π
- Section 2.10.12, Socket Out-of-Band Data State
pselect()recv()recvmsg()
The Base Definitions volume of POSIX.1β2017, <sys_socket.h>
π COPYRIGHT π
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group.
In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
and that's the whole page, bestie!! this one came from IEEE/The Open Group, 2017 β the POSIX Programmer's Manual, SOCKATMARK(3POSIX), published in 2017. ily, go read your socket queues πβ¨ππ¦πΈπ
π«Ά
π¦ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 Β· Other
- debian trixie: manpages-posix-dev 2017a-2 Β· Other
- ubuntu jammy: manpages-posix-dev 2017a-2 Β· Other
- ubuntu noble: manpages-posix-dev 2017a-2 Β· Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 Β· Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 Β· Other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms