| 153 | } |
| 154 | |
| 155 | pub fn blocking_connect( |
| 156 | &self, |
| 157 | network: &Network, |
| 158 | remote_address: IpSocketAddress, |
| 159 | ) -> Result<(InputStream, OutputStream), ErrorCode> { |
| 160 | let timeout = monotonic_clock::subscribe_duration(TIMEOUT_NS); |
| 161 | let sub = self.subscribe(); |
| 162 | |
| 163 | self.start_connect(&network, remote_address)?; |
| 164 | |
| 165 | loop { |
| 166 | match self.finish_connect() { |
| 167 | Err(ErrorCode::WouldBlock) => sub.block_until(&timeout)?, |
| 168 | result => return result, |
| 169 | } |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | pub fn blocking_accept(&self) -> Result<(TcpSocket, InputStream, OutputStream), ErrorCode> { |
| 174 | let timeout = monotonic_clock::subscribe_duration(TIMEOUT_NS); |