OpenCPN/OpenCPN — pull request #128 by stripydog (2014-05-28 20:34:58+00:00)
Title: Make UDP DataStreams Input, Output or Input/Out (like TCP DataStreams)

This patch brings UDP data streams into line with the changes made to TCP. Changes to options.cpp mean the "receive" checkbox is no longer greyed out, so UDP data streams can be made output only. This is a good thing as it avoids having to muck about with priorities when you just want to output UDP data over broadcast.

It looks like there's a lot of changes to datastream.cpp but actually it's mostly just formatting: I removed an if clause in an earlier patch but didn't change the indentation to match: this corrects that.

There's a bit more validation of address/port in options.cpp. Blank address fields are now legit for tcp servers (it's replaced with "0.0.0.0" but "0.0.0.0" is rejected for outbound udp or gpsd. Possibly controversially, if an input-only udp server is specified, any address given will be changed to "0.0.0.0". Whilst this might confuse people, it's actually making it explicit what OpenCPN is doing: ignoring anything that's input here and creating a socket on INADDR_ANY.

In testing this out I realise that there's lots of things needing tidying up: More validation should be done on data streams and those that fail to start properly should be removed from the connection list: Currently Bad Things can happen behind the scenes. I can maybe address that a bit later. Hopefully this patch makes things a little better and not worse :-)