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

Pierre Guillot guillotpierre6 at gmail.com
Sat Feb 27 19:22:26 CET 2021


Hello,

A Camomile user encounters an issue with the [netreceive] object. The main
patch contains [netreceive-u -b 15200] and the plugin is loaded several
times (if the plugin is removed and added to the track several times in a
row or the host application closes and reopened several times in a row),
the object fails to connect with the error message "netreceive: listen
failed: Address already in use (48)". Here is the Github issue:
https://github.com/pierreguillot/Camomile/issues/241.

This issue happens on macOS with the Camomile 1.0.8-beta running with the
latest Pd 0.51-4. The problem is not systematic but is easily reproducible.

This problem doesn't seem to happen in the Pd application if only one
[netreceive] object listens to a specific port. If two [netreceive] objects
listen to the same port, one of the objects cannot listen, and the same
error message appears. Is it normal?

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? If so I can create a PR. If not, what would you
suggest?

P.S. It doesn't seem to be compatible with Windows but a simple #if WIN32
would fix it.

Thank you,
Pierre
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-dev/attachments/20210227/e7ba4b5d/attachment.htm>


More information about the Pd-dev mailing list