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

Invalid socket address when using udp with host name #265

Open
DCsunset opened this issue Sep 24, 2024 · 4 comments
Open

Invalid socket address when using udp with host name #265

DCsunset opened this issue Sep 24, 2024 · 4 comments

Comments

@DCsunset
Copy link

DCsunset commented Sep 24, 2024

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
Copy link
Owner

vi commented Sep 24, 2024

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]?

@DCsunset
Copy link
Author

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
Copy link
Owner

vi commented Sep 24, 2024

What if multiple addresses from the same family is returned?

Shall the address be resolved once or periodically refreshed?

@DCsunset
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants