[PD-dev] netreceive: listen failed: Address already in use

Pierre Guillot guillotpierre6 at gmail.com
Sun Feb 28 09:29:59 CET 2021


Thank you for the clarification! 

So the problem might be that when the patch is closed in the camomile plugin, the connection used by the [netreceive] object is not really detached (I guess internally, it’s not synchronous). So when the patch is reopened, the new connection cannot be done because the address is still already in use.

One solution could be to ensure that the connection is detached when closing a patch. 

But I don’t understand why this is different in Pd and in Camomile...

> Le 27 févr. 2021 à 21:17, IOhannes m zmölnig <zmoelnig at iem.at> a écrit :
> 
> Am 27. Februar 2021 19:22:26 MEZ schrieb Pierre Guillot <guillotpierre6 at gmail.com>:
>> Is it normal?
> 
> yes.
> this is how networking works.
> only a single listener on any given port pet interface.
> 
> 
>> I managed to solve this problem by replacing SO_REUSEADDR to
>> SO_REUSEPORT
>> on the function socket_set_boolopt() (l. 703 of x_net.c). I don't know
>> much
>> about sockets but I understand that it allows two [netreceive] objects
>> to
>> use the same address AND the same port. Do you think this is a proper
>> way
>> of fixing this problem?
> 
> no it's not.
> as you've already discovered, this is not supported on all platforms, and those platforms that do support SO_REUSEPORT, can (and do) implement it very differently.
> in most cases it will allow you to bind to the same port multiple times, but you will not receive data on all clients.
> 
> https://stackoverflow.com/a/14388707
> 
> one possible fix for this is to have a single socket that binds to the port, that serves all `[netreceive]` instances (using that port). this obviously canbonly work if all `[netreceive]` instances live in the same application.
> 
> you might also have luck with multicast.
> 
> 
> mfg.hft.fsl
> IOhannes
> 
> 
> _______________________________________________
> Pd-dev mailing list
> Pd-dev at lists.iem.at
> https://lists.puredata.info/listinfo/pd-dev





More information about the Pd-dev mailing list