[PD-dev] netsend/netreceive UDP ignore ECONNREFUSED

Christof Ressi christof.ressi at gmx.at
Sat Mar 23 00:59:51 CET 2019

ha! the [netsend -u] behaviour has always been a pet peave of mine. I've always wanted to fix this, but didn't find time yet... :-(

personally, I would prefer solution nr. 1 (keep the socket open) as this is how most people expect UDP to work. I don't know how many patches rely on the current behaviour (apart from reconnecting after the socket has been closed). can you think of any sane use cases for this? (I'm only talking about UDP sockets of course).

anyway, I'm already happy if there would be *some* way to keep the socket open, so a flag would be also fine.

regarding improvements to [netsend], have you also considered this? https://github.com/pure-data/pure-data/issues/378

I can also contribute, but only after March.


Gesendet: Freitag, 22. März 2019 um 22:56 Uhr
Von: "Dan Wilcox" <danomatika at gmail.com>
An: pd-dev <pd-dev at lists.iem.at>
Betreff: [PD-dev] netsend/netreceive UDP ignore ECONNREFUSED

Howdy all,
I've been making some proposal work for updates to netsend/netreceive.
One issue is making UDP sending ignore connection refused errors. I have this working by catching the return value from recv():
        /* keep UDP alive */
    if (sys_sockerrno() == ECONNREFUSED && x->x_protocol == SOCK_DGRAM)
(I added sys_sockerrno() to return the socket errno.)
>From my reading on the socket API, sending a UDP message conceptually shouldn't care about whether the receiver is there. However this is detected on a lower networking layer and propagated up to the application layer where it can be used or ignored.
My questions are:
1. Should this ignore silently and not close the connection? I notice mrpeach [udpsend] seems to ignores the first try, then closes the socket on the next failure. However, I like keeping the socket as no errors are thrown and you can easily break than re-establish UDP sending/receiving. This works well with the [netsend] dst & source relays.
2. Should this be a creation argument, say -k? I imagine there are plenty of patches which expect the socket to be closed automatically and respond to a 0 from the connection outlet. On the other hand, as UDP is "connectionless" my thinking is that the conceptual "connection" of a UDP [netsend] (aka outlet) refers to the internal socket and not necessarily that the destination is reachable. With TCP, the connection state more obviously refers to 1-1 connection with the other side.

Dan Wilcox
 _______________________________________________ Pd-dev mailing list Pd-dev at lists.iem.at https://lists.puredata.info/listinfo/pd-dev[https://lists.puredata.info/listinfo/pd-dev]

More information about the Pd-dev mailing list