* [FFmpeg-devel] [PR] avformat/unix: Fix 'operation unsupported' error when reading from unixgram sockets (PR #21655)
@ 2026-02-05 17:19 Rost Kurylo via ffmpeg-devel
0 siblings, 0 replies; only message in thread
From: Rost Kurylo via ffmpeg-devel @ 2026-02-05 17:19 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Rost Kurylo
PR #21655 opened by Rost Kurylo (rost.kurylo)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21655
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21655.patch
Sockets of type SOCK_DGRAM don't support listen(), so it was
impossible to read from "unixgram" sockets in ffmpeg.
To test:
```
ffmpeg -type datagram -listen 1 -i 'unix:/tmp/test' -map 0 -f null -
```
With this change, listen() won't be called on the socket, but semantics similar to SOCK_STREAM are preserved (create a socket file, bind to it, receive packets).
Signed-off-by: Rost Kurylo <rost.kurylo@netint.ca>
>From e5fc29385eef58372e86001f80f996ecaeed4687 Mon Sep 17 00:00:00 2001
From: Rost Kurylo <rost.kurylo@netint.ca>
Date: Wed, 4 Feb 2026 10:07:50 -0800
Subject: [PATCH] avformat/unix: Fix 'operation unsupported' error when reading
from unixgram sockets
Sockets of type SOCK_DGRAM don't support listen(), so it was
impossible to read from "unixgram" sockets in ffmpeg.
Signed-off-by: Rost Kurylo <rost.kurylo@netint.ca>
---
libavformat/unix.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/libavformat/unix.c b/libavformat/unix.c
index 3a0caf96ed..ac6a18c48d 100644
--- a/libavformat/unix.c
+++ b/libavformat/unix.c
@@ -78,11 +78,19 @@ static int unix_open(URLContext *h, const char *filename, int flags)
s->timeout = h->rw_timeout / 1000;
if (s->listen) {
- ret = ff_listen_bind(fd, (struct sockaddr *)&s->addr,
- sizeof(s->addr), s->timeout, h);
- if (ret < 0)
- goto fail;
- fd = ret;
+ if (s->type == SOCK_DGRAM) {
+ ret = bind(fd, (struct sockaddr *)&s->addr, sizeof(s->addr));
+ if (ret) {
+ ret = ff_neterrno();
+ goto fail;
+ }
+ } else {
+ ret = ff_listen_bind(fd, (struct sockaddr *)&s->addr,
+ sizeof(s->addr), s->timeout, h);
+ if (ret < 0)
+ goto fail;
+ fd = ret;
+ }
} else {
ret = ff_listen_connect(fd, (struct sockaddr *)&s->addr,
sizeof(s->addr), s->timeout, h, 0);
--
2.52.0
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-02-05 17:19 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-05 17:19 [FFmpeg-devel] [PR] avformat/unix: Fix 'operation unsupported' error when reading from unixgram sockets (PR #21655) Rost Kurylo via ffmpeg-devel
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git