File tree Expand file tree Collapse file tree 4 files changed +29
-0
lines changed Expand file tree Collapse file tree 4 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,14 @@ impl Receiver<WebSocketStream> {
5050 pub fn shutdown_all ( & mut self ) -> IoResult < ( ) > {
5151 self . inner . get_mut ( ) . shutdown ( Shutdown :: Both )
5252 }
53+
54+ /// Changes whether the receiver is in nonblocking mode.
55+ ///
56+ /// If it is in nonblocking mode and there is no incoming message, trying to receive a message
57+ /// will return an error instead of blocking.
58+ pub fn set_nonblocking ( & self , nonblocking : bool ) -> IoResult < ( ) > {
59+ self . inner . get_ref ( ) . set_nonblocking ( nonblocking)
60+ }
5361}
5462
5563impl < R : Read > ws:: Receiver < DataFrame > for Receiver < R > {
Original file line number Diff line number Diff line change @@ -45,6 +45,11 @@ impl Sender<WebSocketStream> {
4545 pub fn shutdown_all ( & mut self ) -> IoResult < ( ) > {
4646 self . inner . shutdown ( Shutdown :: Both )
4747 }
48+
49+ /// Changes whether the sender is in nonblocking mode.
50+ pub fn set_nonblocking ( & self , nonblocking : bool ) -> IoResult < ( ) > {
51+ self . inner . set_nonblocking ( nonblocking)
52+ }
4853}
4954
5055impl < W : Write > ws:: Sender for Sender < W > {
Original file line number Diff line number Diff line change @@ -126,6 +126,14 @@ impl<'a> Server<'a> {
126126 } ;
127127 Ok ( Connection ( try!( wsstream. try_clone ( ) ) , try!( wsstream. try_clone ( ) ) ) )
128128 }
129+
130+ /// Changes whether the Server is in nonblocking mode.
131+ ///
132+ /// If it is in nonblocking mode, accept() will return an error instead of blocking when there
133+ /// are no incoming connections.
134+ pub fn set_nonblocking ( & self , nonblocking : bool ) -> io:: Result < ( ) > {
135+ self . inner . set_nonblocking ( nonblocking)
136+ }
129137}
130138
131139impl < ' a > Iterator for Server < ' a > {
Original file line number Diff line number Diff line change @@ -83,4 +83,12 @@ impl WebSocketStream {
8383 WebSocketStream :: Ssl ( ref inner) => WebSocketStream :: Ssl ( try!( inner. try_clone ( ) ) ) ,
8484 } )
8585 }
86+
87+ /// Changes whether the stream is in nonblocking mode.
88+ pub fn set_nonblocking ( & self , nonblocking : bool ) -> io:: Result < ( ) > {
89+ match * self {
90+ WebSocketStream :: Tcp ( ref inner) => inner. set_nonblocking ( nonblocking) ,
91+ WebSocketStream :: Ssl ( ref inner) => inner. get_ref ( ) . set_nonblocking ( nonblocking) ,
92+ }
93+ }
8694}
You can’t perform that action at this time.
0 commit comments