TCP/TLS connection pooling for Eio
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 29 lines 989 B view raw
1(*--------------------------------------------------------------------------- 2 Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 SPDX-License-Identifier: ISC 4 ---------------------------------------------------------------------------*) 5 6(** Network endpoint representation *) 7 8let src = 9 Logs.Src.create "conpool.endpoint" ~doc:"Connection pool endpoint operations" 10 11module Log = (val Logs.src_log src : Logs.LOG) 12 13type t = { host : string; port : int } 14 15let v ~host ~port = 16 (* Validate port range *) 17 if port < 1 || port > 65535 then 18 Fmt.invalid_arg "Invalid port number: %d (must be 1-65535)" port; 19 20 (* Validate hostname is not empty *) 21 if String.trim host = "" then invalid_arg "Hostname cannot be empty"; 22 23 { host; port } 24 25let host t = t.host 26let port t = t.port 27let equal t1 t2 = String.equal t1.host t2.host && t1.port = t2.port 28let hash t = Hashtbl.hash (t.host, t.port) 29let pp = Fmt.of_to_string (fun t -> Fmt.str "%s:%d" t.host t.port)