sig
  module Address :
    sig
      module Unix :
        sig
          type t = [ `Unix of string ]
          val create : string -> t
          val to_string : t -> string
          val compare : t -> t -> int
          val t_of_sexp : Sexplib.Sexp.t -> t
          val __t_of_sexp__ : Sexplib.Sexp.t -> t
          val sexp_of_t : t -> Sexplib.Sexp.t
          val bin_t : t Core.Std.Bin_prot.Type_class.t
          val bin_read_t : t Core.Std.Bin_prot.Read.reader
          val __bin_read_t__ : (int -> t) Core.Std.Bin_prot.Read.reader
          val bin_reader_t : t Core.Std.Bin_prot.Type_class.reader
          val bin_size_t : t Core.Std.Bin_prot.Size.sizer
          val bin_write_t : t Core.Std.Bin_prot.Write.writer
          val bin_writer_t : t Core.Std.Bin_prot.Type_class.writer
        end
      module Inet :
        sig
          type t = [ `Inet of Unix_syscalls.Inet_addr.t * int ]
          val create : Unix_syscalls.Inet_addr.t -> port:int -> t
          val create_bind_any : port:int -> t
          val addr : t -> Unix_syscalls.Inet_addr.t
          val port : t -> int
          val to_string : t -> string
          val compare : t -> t -> int
          val t_of_sexp : Sexplib.Sexp.t -> t
          val __t_of_sexp__ : Sexplib.Sexp.t -> t
          val sexp_of_t : t -> Sexplib.Sexp.t
          val bin_t : t Core.Std.Bin_prot.Type_class.t
          val bin_read_t : t Core.Std.Bin_prot.Read.reader
          val __bin_read_t__ : (int -> t) Core.Std.Bin_prot.Read.reader
          val bin_reader_t : t Core.Std.Bin_prot.Type_class.reader
          val bin_size_t : t Core.Std.Bin_prot.Size.sizer
          val bin_write_t : t Core.Std.Bin_prot.Write.writer
          val bin_writer_t : t Core.Std.Bin_prot.Type_class.writer
        end
      type t = [ `Inet of Unix_syscalls.Inet_addr.t * int | `Unix of string ]
      val to_string : [< t ] -> string
      val to_sockaddr : [< t ] -> Core.Std.Unix.sockaddr
      val t_of_sexp : Sexplib.Sexp.t -> t
      val __t_of_sexp__ : Sexplib.Sexp.t -> t
      val sexp_of_t : t -> Sexplib.Sexp.t
      val bin_t : t Core.Std.Bin_prot.Type_class.t
      val bin_read_t : t Core.Std.Bin_prot.Read.reader
      val __bin_read_t__ : (int -> t) Core.Std.Bin_prot.Read.reader
      val bin_reader_t : t Core.Std.Bin_prot.Type_class.reader
      val bin_size_t : t Core.Std.Bin_prot.Size.sizer
      val bin_write_t : t Core.Std.Bin_prot.Write.writer
      val bin_writer_t : t Core.Std.Bin_prot.Type_class.writer
    end
  module Family :
    sig
      type 'a t = 'Unix_syscalls.Socket.Family.t
        constraint 'a = [< Address.t ]
      val unix : Address.Unix.t t
      val inet : Address.Inet.t t
      val to_string : [< Address.t ] t -> string
    end
  type ('a, 'b) t = ('a, 'b) Unix_syscalls.Socket.t
    constraint 'a = [< `Active | `Bound | `Passive | `Unconnected ]
    constraint 'b = [< Address.t ]
  module Type :
    sig
      type 'a t = 'Unix_syscalls.Socket.Type.t
        constraint 'a = [< Address.t ]
      val tcp : Address.Inet.t t
      val udp : Address.Inet.t t
      val unix : Address.Unix.t t
      val unix_dgram : Address.Unix.t t
    end
  val create : ([< Address.t ] as 'a) Type.t -> ([ `Unconnected ], 'a) t
  val connect :
    ([ `Unconnected ], [< Address.t ] as 'a) t ->
    '-> ([ `Active ], 'a) t Import.Deferred.t
  val connect_interruptible :
    ([ `Unconnected ], [< Address.t ] as 'a) t ->
    '->
    interrupt:unit Import.Deferred.t ->
    [ `Interrupted | `Ok of ([ `Active ], 'a) t ] Import.Deferred.t
  val bind :
    ([ `Unconnected ], [< Address.t ] as 'a) t ->
    '-> ([ `Bound ], 'a) t Import.Deferred.t
  val listen :
    ?max_pending_connections:int ->
    ([ `Bound ], [< Address.t ] as 'a) t -> ([ `Passive ], 'a) t
  val accept :
    ([ `Passive ], [< Address.t ] as 'a) t ->
    [ `Ok of ([ `Active ], 'a) t * '| `Socket_closed ] Import.Deferred.t
  val accept_interruptible :
    ([ `Passive ], [< Address.t ] as 'a) t ->
    interrupt:unit Import.Deferred.t ->
    [ `Interrupted | `Ok of ([ `Active ], 'a) t * '| `Socket_closed ]
    Import.Deferred.t
  val shutdown :
    ([< `Active | `Bound | `Passive | `Unconnected ], [< Address.t ]) t ->
    [ `Both | `Receive | `Send ] -> unit
  val fd :
    ([< `Active | `Bound | `Passive | `Unconnected ], [< Address.t ]) t ->
    Fd.t
  val of_fd :
    Fd.t ->
    ([< Address.t ] as 'a) Type.t ->
    ([< `Active | `Bound | `Passive | `Unconnected ], 'a) t
  val getsockname :
    ([< `Active | `Bound | `Passive | `Unconnected ], [< Address.t ] as 'a) t ->
    'a
  val getpeername :
    ([< `Active | `Bound | `Passive | `Unconnected ], [< Address.t ] as 'a) t ->
    'a
  module Opt :
    sig
      type 'a t = 'Unix_syscalls.Socket.Opt.t
      val debug : bool t
      val broadcast : bool t
      val reuseaddr : bool t
      val keepalive : bool t
      val dontroute : bool t
      val oobinline : bool t
      val acceptconn : bool t
      val nodelay : bool t
      val sndbuf : int t
      val rcvbuf : int t
      val error : int t
      val typ : int t
      val rcvlowat : int t
      val sndlowat : int t
      val linger : int option t
      val rcvtimeo : float t
      val sndtimeo : float t
      val mcast_loop : bool t
      val mcast_ttl : int t
      val to_string : 'a t -> string
    end
  val getopt :
    ([< `Active | `Bound | `Passive | `Unconnected ], [< Address.t ]) t ->
    'Opt.t -> 'c
  val setopt :
    ([< `Active | `Bound | `Passive | `Unconnected ], [< Address.t ]) t ->
    'Opt.t -> '-> unit
  val mcast_join :
    ?ifname:string ->
    ([< `Active | `Bound | `Passive | `Unconnected ], [< Address.t ] as 'a) t ->
    '-> unit
  val mcast_leave :
    ?ifname:string ->
    ([< `Active | `Bound | `Passive | `Unconnected ], [< Address.t ] as 'a) t ->
    '-> unit
  val sexp_of_t :
    (([< `Active | `Bound | `Passive | `Unconnected ] as 'a) ->
     Sexplib.Sexp.t) ->
    (([< Address.t ] as 'b) -> Sexplib.Sexp.t) ->
    ('a, 'b) t -> Sexplib.Sexp.t
end