vi/websocat

Invalid socket address when using udp with host name

DCsunset opened this issue · 4 comments

When using udp: with a host name, it throws an error:

$ websocat -E -b ws-listen:0.0.0.0:8080 udp:example.com:8080
websocat: invalid socket address syntax

However, tcp works as expected:

$ websocat -E -b ws-listen:0.0.0.0:8080 tcp:example.com:8080
vi commented

There is a special support for TCP with hostnames (it supports trying multiple resolved addresses and choosing the one that works). This support appeared relatively late in Websocat history.

What shall udp:example.com do if it resolves to e.g. 1.2.3.4 and [5678::9]?

That's a good point. I think one approach is to use a random address (usually both should work). Another approach is to add udp4 and udp6 as socat does.

vi commented

What if multiple addresses from the same family is returned?

Shall the address be resolved once or periodically refreshed?

For the first question, I think using the first one should be good for most cases and is easy to implement. (If any address doesn't work, it should be the responsibility of the server instead of this app)

For the second question, I think either approach is good enough for most apps to work.