[PD] ugly "already connected" errors

Christof Ressi christof.ressi at gmx.at
Fri Jan 25 21:09:08 CET 2019


> the sender socket is in some cases
> notified about the termination of the receiving socket.

this what happens in Pd with [netsend -u], but it's *not* what one would expect from UDP. on all the socket libraries I've used, "connect" doesn't do much on a UDP socket, it only sets the default address, so you don't have to provide it explicitly for every datagram you send, and you can change it whenever you like.
see also: http://man7.org/linux/man-pages/man2/connect.2.html

So UDP shouldn't really know if the destination socket actually exists because there is no established connection. I actually filed a bug report which is somehow related to this: https://github.com/pure-data/pure-data/issues/373

Note that [udpsend] from iemlib / mrpeach behaves correctly in that it doesn't stop working if the destination doesn't exist.

I promised to look at the code and find out what's really going on in [netsend -u] but I didn't have time yet :-(

Christof


> Gesendet: Freitag, 25. Januar 2019 um 15:35 Uhr
> Von: "Roman Haefeli" <reduzent at gmail.com>
> An: pd-list at lists.iem.at
> Betreff: Re: [PD] ugly "already connected" errors
>
> What you found, challenged my understanding of UDP and it seems,
> depending on implementation, the sender socket is in some cases
> notified about the termination of the receiving socket. 
> 
> When I connect [netsend -u] to a small python script that opens a
> listening socket, i can kill the script and start it again and [netsend
> -u] can still send packets. When I connect to 'nc -v -u -l -p 11579'
> instead, [netsend -b] can send packets only as long as the process is
> running. When I kill nc and start it again, no messages reach their
> destination anymore. I have to 'disconnect' and 'connect'. 
> 
> So what kind of software is opening the listening socket on the phone? 
> 
> Roman
> 
> On Fri, 2019-01-25 at 15:14 +0100, Roman Haefeli wrote:
> > On Fri, 2019-01-25 at 15:01 +0100, michael strohmann wrote:
> > > thanks for the answer!
> > > but, 
> > > in order to show that there is a connection betwenn the app to pd i
> > > do:
> > > 
> > > [metro 1000]
> > > > 
> > > 
> > > [toggle(					
> > > > 
> > > 
> > > [oscformat BlinkingButton/value]
> > > > 
> > > 
> > > [list prepend send]
> > > > 
> > > 
> > > [list trim]
> > > >    \
> > > > 	[t b]
> > > > 	|
> > > > 	[disconnect, connect 192.168.178.189 8000(
> > > >    /
> > > 
> > > [netsend -u -b] 
> > > 
> > > now everytime the phone is not available i get:
> > > recv: Connection refused (111)
> > > netsend: Bad file descriptor (9)
> > > warning: 35 removed from poll list but not found
> > > 
> > > if i dont disconnect before sending i get the “already connected”
> > > error.
> > > and if i only connect once and leave the pd side connected, no
> > > messages are received on the phone once it leaves the wlan.
> > > 
> > > messages sent from the phone are almost always received.
> > > 
> > > in any case it get a console message, either “connecting to port
> > > 8000” or “already connected”
> > > 
> > > i am just concerned because my patch crashes or freezes or create
> > > glitchy digital artefacts from time to time, and since it is a 24/7
> > > audio installation i would like it to work.
> > > how to find these bugs...
> > 
> > Oh, I see. That's much messier than I thought. I always believed an
> > UDP
> > socket stays open regardless of the presence of the other end. But
> > seems to be not fully true. I'm not sure what's going on but it looks
> > like the OS closes the socket without [netsend] actually noticing
> > it. 
> > 
> > I would try what Antoine suggested and send a 'disconnect' each time
> > before you connect again. There should be no harm in 'disconnect'ing
> > and 'connect'ing many times.
> > 
> > Roman
> > 
> _______________________________________________
> Pd-list at lists.iem.at mailing list
> UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
>





More information about the Pd-list mailing list