Not knowing how serious you wish the class to be(come) I thought to mention it.
It should at least work on Windows and Linux with Router UPnP enabled and disabled.
I've just switched to socket (from Synapse) so it could contain some bugs.
But I've just tested it here and even when disabling the UPnP, it timeout correctly for me.
The broadcast option seems to do as suggested as it returns a zero then setting the timeout returns a -1 for me (edit: should that not be a ttimeval struct = 2x 64 bit on 64-bit Linux ?).
Yes, Thank you. I fixed that one.
The following bind also returns a -1 for me.
Strangely enough the sendto then returns a 101 to finally "hang" indefinitely at the call to fprecvfrom.
I'm not entirely sure the fpbind() is needed. I can comment it out and it still works for me (I receive several other M-SEARCH results).
I'm new to the whole raw sockets so there might be an easier way to do this in fpc (maybe with fcl-net).
It works now for me when UPnP is disabled (it searches and waits about 6 seconds before giving up).
If it still hangs for you I need to look at the timeouts again.