Opened 7 months ago

Last modified 6 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)

comment:1 by waddlesplash, 6 months ago

It appears SO_REUSEPORT may also be needed?

in reply to:  1 comment:2 by jeremy-list, 6 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.