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

Modify some parameters of udp connection #130

Closed
Be33eD opened this issue Sep 7, 2022 · 2 comments · Fixed by #145
Closed

Modify some parameters of udp connection #130

Be33eD opened this issue Sep 7, 2022 · 2 comments · Fixed by #145

Comments

@Be33eD
Copy link

Be33eD commented Sep 7, 2022

Hi,

I noticed that '0.0.0.0:0' is used in the code, which means a random port is assigned. Is there some way I can bind UDP to a specified port?

fn connect(remote_addr: RemoteAddr) -> io::Result<ConnectionInfo<Self>> {
    let socket = UdpSocket::bind("0.0.0.0:0".parse().unwrap())?;
    let peer_addr = *remote_addr.socket_addr();
    socket.connect(peer_addr)?;
    let local_addr = socket.local_addr()?;
    Ok(ConnectionInfo { remote: RemoteResource { socket }, local_addr, peer_addr })
}

Also, can I set some timeout on read/write, for example using set_read_timeout()/set_write_timeout().

@lemunozm
Copy link
Owner

lemunozm commented Sep 8, 2022

HI @Be33eD, yes it's hardcoded when you perform an output connection. When you listen, you can specify the port.

This more "advance" configuration, along with the timeout configuration is not supported currently in message-io. There is an open issue where I wanted to add some configuration transport-related properties at connect/listen calls. In those configurations, you could specify these kinds of things as local port, timeouts, etc.

Currently, I do not have time to tackle new features on message-io, only some bugs/issues. Maybe in a near future. Sorry for the inconvenience. Of course, if any brave person wants to make a PR with this, I will give them all my support.

@Be33eD
Copy link
Author

Be33eD commented Sep 9, 2022

Thanks a lot for your reply and work on message-io, it's a really great library.

I will continue to try other ways to solve this problem.

@Be33eD Be33eD closed this as completed Sep 9, 2022
This was referenced Mar 17, 2023
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

Successfully merging a pull request may close this issue.

2 participants