Folks,
I have found a problem with the handling of UDP sockets in drvAsynIPPort. The problem arises when a broadcast socket is created using the IP protocol string “UDP*” in
the call to drvAsynIPPortConfigure(). Calls to asynOctet->write() are OK, broadcast messages get sent correctly. However, if a client attempts to reply to such a broadcast (using the ephemeral source port number that was sent in the broadcast message) then
that reply is rejected by the host that sent the broadcast.
The problem is that the current version of drvAsynIPPort always calls connect() on all sockets, including UDP sockets. It then calls send() and recv() to write and read
from the socket respectively. This does not work correctly in the case of UDP broadcast sockets.
I have created a new issue for the problem on github:
https://github.com/epics-modules/asyn/issues/11
The problem is fixed by doing the following for broadcast UDP sockets:
- Don't call connect()
- Call sendto() rather than send()
- Call recvfrom() rather than recv()
Eric Norum and I cannot think of a reason not to make the above changes for all UDP sockets, not just broadcast sockets. I have made a new udp_fixes branch on github
that implements the above changes for all drvAsynIPPort UDP ports.
https://github.com/epics-modules/asyn/tree/udp_fixes
I have tagged the current version of that branch as the R4-28beta1 release.
I would like to encourage comments and testing of these changes before I release asyn R4-28. If you currently use UDP sockets with asyn please try to test by either checking
out the udp_fixes branch or downloading the tar or zip file for R4-28beta1 release.
Thanks,
Mark