Add a keep-alive and timeout demo to the examples.
parent
cfcbcea4eb
commit
42b3a71f72
|
@ -206,7 +206,8 @@ It responds to:
|
|||
* TCP connections on port 6970 (`socat stdio tcp4-connect:192.168.69.1:6970 <<<"abcdefg"`),
|
||||
where it will respond with reversed chunks of the input indefinitely.
|
||||
* TCP connections on port 6971 (`socat stdio tcp4-connect:192.168.69.1:6971 </dev/urandom`),
|
||||
which will sink data.
|
||||
which will sink data. Also, keep-alive packets (every 1 s) and a user timeout (at 2 s)
|
||||
are enabled on this port; try to trigger them using fault injection.
|
||||
* TCP connections on port 6972 (`socat stdio tcp4-connect:192.168.69.1:6972 >/dev/null`),
|
||||
which will source data.
|
||||
|
||||
|
|
|
@ -147,7 +147,9 @@ fn main() {
|
|||
{
|
||||
let socket: &mut TcpSocket = sockets.get_mut(tcp3_handle).as_socket();
|
||||
if !socket.is_open() {
|
||||
socket.listen(6971).unwrap()
|
||||
socket.listen(6971).unwrap();
|
||||
socket.set_keep_alive(Some(1000));
|
||||
socket.set_timeout(Some(2000));
|
||||
}
|
||||
|
||||
if socket.may_recv() {
|
||||
|
|
Loading…
Reference in New Issue