EOPNOTSUPP
Linux / POSIXERRORCommonNetworkHIGH confidence
Operation Not Supported
Production Risk
Programming error; operation not valid for this socket/file type.
What this means
EOPNOTSUPP (errno 95) is returned when an operation is not supported for the given object type. Commonly seen on sockets (e.g., accept() on SOCK_DGRAM) and filesystems (e.g., fcntl on a FIFO).
Why it happens
- 1Calling accept() on a SOCK_DGRAM socket
- 2listen() on a SOCK_DGRAM socket
- 3Requesting an unsupported filesystem operation (e.g., FALLOC_FL_COLLAPSE_RANGE on ext3)
How to reproduce
accept() called on a UDP socket.
trigger — this will error
trigger — this will error
int sockfd = socket(AF_INET, SOCK_DGRAM, 0); // accept() is only valid for connection-oriented sockets accept(sockfd, NULL, NULL); // Returns -1, errno = EOPNOTSUPP
expected output
accept: Operation not supported (EOPNOTSUPP)
Fix
Use the correct socket type for the operation
WHEN When accept()/listen() return EOPNOTSUPP
Use the correct socket type for the operation
// Use SOCK_STREAM for connection-oriented operations int sockfd = socket(AF_INET, SOCK_STREAM, 0); bind(sockfd, (struct sockaddr*)&addr, sizeof(addr)); listen(sockfd, 10); int client = accept(sockfd, NULL, NULL);
Why this works
accept() and listen() require SOCK_STREAM (TCP) or SOCK_SEQPACKET; not valid for SOCK_DGRAM.
Sources
Official documentation ↗
Linux Programmer Manual accept(2)
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev