@@ -58,6 +58,10 @@ let error fmt =
58
58
59
59
let parse_third_party_cap_id _ = `Two_party_only
60
60
61
+ let try_set_nodelay socket =
62
+ try Unix. setsockopt socket Unix. TCP_NODELAY true
63
+ with Unix. Unix_error (EOPNOTSUPP, _ , _ ) -> () (* Probably a Unix-domain socket *)
64
+
61
65
let connect net ~sw ~secret_key (addr , auth ) =
62
66
let eio_addr =
63
67
match addr with
@@ -76,6 +80,7 @@ let connect net ~sw ~secret_key (addr, auth) =
76
80
let socket = Eio_unix.Resource. fd_opt socket |> Option. get in
77
81
Eio_unix.Fd. use_exn " keep-alive" socket @@ fun socket ->
78
82
Unix. setsockopt socket Unix. SO_KEEPALIVE true ;
83
+ try_set_nodelay socket;
79
84
Keepalive. try_set_idle socket 60
80
85
end;
81
86
Tls_wrapper. connect_as_client socket secret_key auth
@@ -84,6 +89,8 @@ let connect net ~sw ~secret_key (addr, auth) =
84
89
error " @[<v2>Network connection for %a failed:@,%a@]" Location. pp addr Fmt. exn ex
85
90
86
91
let accept_connection ~secret_key flow =
92
+ Eio_unix.Resource. fd_opt flow
93
+ |> Option. iter (fun fd -> Eio_unix.Fd. use_exn " TCP_NODELAY" fd try_set_nodelay);
87
94
Tls_wrapper. connect_as_server flow secret_key
88
95
89
96
let v t = (t :> [`Generic] Eio.Net.ty r )
0 commit comments