Opened 14 months ago
Last modified 13 months ago
#18610 new bug
"reuseAddr" argument of BDatagramSocket::Bind is ignored
Reported by: | jeremy-list | Owned by: | axeld |
---|---|---|---|
Priority: | normal | Milestone: | Unscheduled |
Component: | Network & Internet/UDP | Version: | R1/beta4 |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Platform: | All |
Description
When the following code is run, the string "Address already in use" is printed to the standard output, which is inappropriate because the reuseAddr
argument is true on both binds.
BDatagramSocket socket; BDatagramSocket socket2; BNetworkAddress address; status_t status; address.SetToWildcard(AF_INET, 8008); if ((status = socket.Bind(address, true)) != B_OK) std::cout << strerror(status) << std::endl; if ((status = socket.SetBroadcast(true)) != B_OK) std::cout << strerror(status) << std::endl; if ((status = socket2.Bind(address, true)) != B_OK) std::cout << strerror(status) << std::endl; if ((status = socket2.SetBroadcast(true)) != B_OK) std::cout << strerror(status) << std::endl;
This is something of an obstacle to local testing of software for Haiku that uses UDP broadcast packets.
Change History (2)
follow-up: 2 comment:1 by , 13 months ago
comment:2 by , 13 months ago
Replying to waddlesplash:
It appears SO_REUSEPORT may also be needed?
Yes you're right. It's a little unfortunate that this can't be done directly on the BDatagramSocket
but working around that limitation isn't too difficult. I believe this ticket can be closed.
Note:
See TracTickets
for help on using tickets.
It appears SO_REUSEPORT may also be needed?