Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CommsUDPSerialConnect multicast to allow address reuse #3144

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Controls/SerialOutputCoT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ void mainloop()

if (CoTStream != null && CoTStream.IsOpen)
{
CoTStream.WriteLine(xmlStr.Replace("\r", ""));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't remember why I added this but it doesn't really do anything and doesn't belong in this PR.

CoTStream.Write(xmlStr.Replace("\r", ""));
}
});
});
Expand Down
6 changes: 5 additions & 1 deletion ExtLibs/Comms/CommsUDPSerialConnect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ public void Open(string host, string port)
if (IsInRange("224.0.0.0", "239.255.255.255", hostEndPoint.Address.ToString()))
{
log.Info($"UdpSerialConnect bind to port {Port}");
client = new UdpClient(int.Parse(Port), hostEndPoint.AddressFamily);

client = new UdpClient();
client.ExclusiveAddressUse = false;
client.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
client.Connect(hostEndPoint.Address, hostEndPoint.Port);
Copy link
Contributor

@meee1 meee1 Jul 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this actually removes the bind port, and changes to a connect vs a bind and listen

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly. We don't want to bind. We want two apps to be able to use the same multicast ip and port. If you don't like that, I suppose we could add a checkbox to enable/allow port-reuse in the CoT menu


IsOpen = true;

Expand Down