withoutboats / romio

asynchronous networking primitives

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Read timeout on UdpSocket ?

snakehand opened this issue · comments

I am having problems setting read timeout on the UdpSocket.

I can set timeout on a mio::net::UdpScoket, but can't transfer that using UdpSocket::new() since the method is private.

Neither can i do let socket_rx = UdpSocket{ io: PollEvented::new(msocket) }; - since the ractor::PollEvented is also private.

Is there a way around this, or does it require a code change ?

Probably the solution is to add the method back to romio's UdpSocket.

I just tried this on a local checkout - but it doesn't seem to accomplish what I desire. I.e. the the await! does not "return" when the socket read should have timed out. I guess this could be connected to how epoll() works ? - So I am left wondering what the correct way should be to have a socket read time out ?

I am beginning to wonder if what I really need is an equivalent to tokio::timer::Delay.
Besides being useful by itself ( for standoff etc.), I also think it can be used together with select2() to provide the timeout functionality on read(). However select2() seems to be currently missing from the futures-preview 0.3 crate. So I am pretty much stuck, unless I want to get heavily involved in development of core crates :-)

I think implementing timer-queues and select2() for futures-preview is probably outside of scope for this demo / teaser crate at the moment. I will close the issue.