Commits

Anonymous committed 0a16348

Submit cf-0.1 release.

Comments (0)

Files changed (14)

 (*---------------------------------------------------------------------------*
   IMPLEMENTATION  cf_monad.ml
 
-  Copyright (c) 2002, James H. Woodyatt
+  Copyright (c) 2002-2004, James H. Woodyatt
   All rights reserved.
 
   Redistribution and use in source and binary forms, with or without
 let modify f s = (), (f s)
 let field f s = (f s), s
 
-open Op
-
-let accumulate =
-    let rec loop stack seq =
-        match Lazy.force seq with
-        | Cf_seq.P (hd, tl) -> hd >>= fun x -> loop (x :: stack) tl
-        | Cf_seq.Z -> return (List.rev stack)
-    in
-    fun s -> loop [] s
-
-let rec sequence s =
-    match Lazy.force s with
-    | Cf_seq.P (hd, tl) -> hd >>= fun _ -> sequence tl
-    | Cf_seq.Z -> return ()
-
 (*--- End of File [ cf_monad.ml ] ---*)
 (*---------------------------------------------------------------------------*
   INTERFACE  cf_smonad.mli
 
-  Copyright (c) 2002, James H. Woodyatt
+  Copyright (c) 2002-2004, James H. Woodyatt
   All rights reserved.
 
   Redistribution and use in source and binary forms, with or without
 *)
 val field: ('s -> 'a) -> ('s, 'a) t      (* let field f s = (f s), s         *)
 
-(** Use [accumulate seq] to produce a monad that evaluates a sequence of monads
-    [seq] and returns a list of the results.
-*)
-val accumulate: ('s, 'a) t Cf_seq.t -> ('s, 'a list) t
-
-(** Use [sequence seq] to produce a monad that evaluates a sequence of monads
-    [seq] and discards all the results.
-*)
-val sequence: ('s, 'a) t Cf_seq.t -> ('s, unit) t
-
 (*--- End of File [ cf_smonad.mli ] ---*)

cf/cf_sock_common.ml

 (*---------------------------------------------------------------------------*
   IMPLEMENTATION  cf_sock_common.ml
 
-  Copyright (c) 2003, James H. Woodyatt
+  Copyright (c) 2003-2004, James H. Woodyatt
   All rights reserved.
 
   Redistribution and use in source and binary forms, with or without
         
             method private getsockname: address_t
             method private getpeername: address_t
-            
-            method private send:
-                ?flags:Cf_socket.msg_flags_t -> string -> int -> int -> int
-            method private recv:
-                ?flags:Cf_socket.msg_flags_t -> string -> int -> int -> int
-                    
+                        
             method private shutdown: Unix.shutdown_command -> unit
             
             method private bind: address_t -> unit
         
             method private getsockname = P.AF.of_sockaddr (getsockname socket_)
             method private getpeername = P.AF.of_sockaddr (getpeername socket_)
-            
-            method private send ?(flags = msg_flags_none) msg pos len =
-                send socket_ msg pos len flags
-            
-            method private recv ?(flags = msg_flags_none) msg pos len =
-                recv socket_ msg pos len flags
                         
             method private shutdown cmd = shutdown socket_ cmd
             

cf/cf_sock_common.mli

 (*---------------------------------------------------------------------------*
   INTERFACE  cf_sock_common.mli
 
-  Copyright (c) 2003, James H. Woodyatt
+  Copyright (c) 2003-2004, James H. Woodyatt
   All rights reserved.
 
   Redistribution and use in source and binary forms, with or without
                 error.
             *)
             method private getpeername: address_t
-            
-            (** Use [self#send ?flags buf pos len] to send [len] octets from
-                the string [buf] starting at position [pos], optionally with
-                the flags indicated by [flags].  Returns the number of octets
-                actually sent.  Raises [Unix.Error] if there is an error.
-                Raises [Invalid_argument] if [pos] and [len] do not correspond
-                to a valid substring of [buf].
-            *)
-            method private send:
-                ?flags:Cf_socket.msg_flags_t -> string -> int -> int -> int
-    
-            (** Use [obj#recv ?flags buf pos len] to receive [len] octets to
-                the string [buf] starting at position [pos], optionally with
-                the flags indicated by [flags].  Returns the number of octets
-                actually received.  Raises [Unix.Error] if there is an error.
-                Raises [Invalid_argument] if [pos] and [len] do not correspond
-                to a valid substring of [buf].
-            *)
-            method private recv:
-                ?flags:Cf_socket.msg_flags_t -> string -> int -> int -> int
-                    
+                        
             (** Use [obj#shutdown cmd] to shutdown either sending or receiving
                 (or both) on the socket.  Raises [Unix.Error] if there is an
                 error.

cf/cf_sock_dgram.ml

+(*---------------------------------------------------------------------------*
+  IMPLEMENTATION  cf_sock_dgram.ml
+
+  Copyright (c) 2004, James H. Woodyatt
+  All rights reserved.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions
+  are met:
+
+    Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+
+    Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in
+    the documentation and/or other materials provided with the
+    distribution
+
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+  ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+  COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+  OF THE POSSIBILITY OF SUCH DAMAGE. 
+ *---------------------------------------------------------------------------*)
+
+external init_: unit -> unit = "cf_sock_dgram_init";;
+init_ ();;
+
+external socktype_lift:
+    unit -> 'a Cf_socket.socktype_t = "cf_sock_dgram_socktype_lift"
+
+module ST = struct
+    type tag_t = [ `SOCK_DGRAM ]
+    let socktype = socktype_lift ()
+end
+
+module type T = sig
+    include Cf_sock_common.T
+
+    class endpoint:
+        t ->
+        object('self)
+            inherit basic
+            constraint 'self = #Cf_sock_common.endpoint
+            
+            method virtual getsockname: address_t
+
+            method sendto:
+                ?flags:Cf_socket.msg_flags_t -> string -> int -> int ->
+                address_t -> int
+
+            method recvfrom:
+                ?flags:Cf_socket.msg_flags_t -> string -> int -> int ->
+                int * address_t
+
+            method connect: address_t -> unit
+
+            method virtual getpeername: address_t
+
+            method send:
+                ?flags:Cf_socket.msg_flags_t -> string -> int -> int -> int
+            method recv:
+                ?flags:Cf_socket.msg_flags_t -> string -> int -> int -> int
+
+            method virtual shutdown: Unix.shutdown_command -> unit
+        end
+end
+
+module Create(P: Cf_socket.P with module ST = ST) = struct
+    include Cf_sock_common.Create(P)
+    
+    module S0 = Cf_socket
+    
+    class endpoint sock =
+        object
+            inherit basic ~sock ()
+            
+            method virtual getsockname: address_t
+
+            method sendto ?(flags = S0.msg_flags_none) msg pos len addr =
+                let addr = P.AF.to_sockaddr addr in
+                S0.sendto socket_ msg pos len flags addr
+
+            method recvfrom ?(flags = S0.msg_flags_none) msg pos len =
+                let n, addr = S0.recvfrom socket_ msg pos len flags in
+                n, P.AF.of_sockaddr addr
+
+            method connect addr =
+                let addr = P.AF.to_sockaddr addr in
+                S0.connect socket_ addr
+
+            method virtual getpeername: address_t
+            
+            method virtual shutdown: Unix.shutdown_command -> unit
+            
+            method send ?(flags = S0.msg_flags_none) msg pos len =
+                S0.send socket_ msg pos len flags
+            
+            method recv ?(flags = S0.msg_flags_none) msg pos len =
+                S0.recv socket_ msg pos len flags
+            
+        end
+end
+
+(*--- End of File [ cf_sock_dgram.ml ] ---*)

cf/cf_sock_dgram.mli

+(*---------------------------------------------------------------------------*
+  INTERFACE  cf_sock_dgram.mli
+
+  Copyright (c) 2004, James H. Woodyatt
+  All rights reserved.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions
+  are met:
+
+    Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+
+    Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in
+    the documentation and/or other materials provided with the
+    distribution
+
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+  ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+  COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+  OF THE POSSIBILITY OF SUCH DAMAGE. 
+ *---------------------------------------------------------------------------*)
+
+(** Connection-oriented dgram transports with orderly release.
+
+    This module extends the basic sockets interfaces defined in {!Cf_socket}
+    and {!Cf_sock_common} with support for sockets of type [SOCK_DGRAM], i.e.
+    connectionless transport (w/ optional multicast).  UDP endpoints are
+    sockets of this type.
+*)
+
+(** The module defining the [SOCK_DGRAM] socket type. *)
+module ST: Cf_socket.ST with type tag_t = [ `SOCK_DGRAM ]
+
+(** The type of the module containing the extensions to the {!Cf_sock_common.T}
+    module type used for handling sockets of the [SOCK_DGRAM] socket type.
+*)
+module type T = sig
+    include Cf_sock_common.T
+
+    (** Use [new endpoint sock] to construct an object derived from
+        {!Cf_sock_common.T.basic} that sports methods for sending data to one
+        or more endpoints using the socket [sock].
+    *)
+    class endpoint:
+        t ->
+        object('self)
+            inherit basic
+            constraint 'self = #Cf_sock_common.endpoint
+            
+            (** Use [obj#getsockname] to obtain the actual local address
+                associated with the socket.  Raises [Unix.Error] if there is an
+                error.
+            *)
+            method virtual getsockname: address_t
+
+            (** Use [self#sendto ?flags buf pos len addr] to send [len] octets
+                from the string [buf] starting at position [pos] to the remote
+                address [addr], and optionally with the flags indicated by
+                [flags].  Returns the number of octets actually sent.  Raises
+                [Unix.Error] if there is an error.  Raises [Invalid_argument]
+                if [pos] and [len] do not correspond to a valid substring of
+                [buf].
+            *)
+            method sendto:
+                ?flags:Cf_socket.msg_flags_t -> string -> int -> int ->
+                address_t -> int
+            
+            (** Use [recvfrom sock buf pos len flags] to receive [len] octets
+                into the string [buf] starting at position [pos] on the socket
+                [sock] with the flags indicated by [flags].  Returns the number
+                of octets actually received and the socket address of the
+                remote endpoint that sent them.  Raises [Unix.Error] if there
+                is an error.  Raises [Invalid_argument] if [pos] and [len] do
+                not correspond to a valid substring of [buf].
+            *)
+            method recvfrom:
+                ?flags:Cf_socket.msg_flags_t -> string -> int -> int ->
+                int * address_t
+
+            (** Use [obj#connect] to associate the socket with the remote
+                address [address].  Enables the use of the [getpeername],
+                [send] and [recv] methods (may not be supported by all
+                protocols).
+            *)
+            method connect: address_t -> unit
+
+            (** Use [obj#getpeername] to obtain the actual remote address
+                associated with the socket.  Raises [Unix.Error] if there is an
+                error.  If there is no remote address associated with the
+                socket, then a protocol-specific response is provided.  Most
+                protocols will return an address indicated the remote address
+                is unspecified.
+            *)
+            method virtual getpeername: address_t
+
+            (** Use [self#send ?flags buf pos len] to send [len] octets from
+                the string [buf] starting at position [pos] to the remote
+                address previously associated with the socket using the
+                [connect] method, and optionally with the flags indicated by
+                [flags].  Returns the number of octets actually sent.  Raises
+                [Unix.Error] if there is an error.  Raises [Invalid_argument]
+                if [pos] and [len] do not correspond to a valid substring of
+                [buf].
+            *)
+            method send:
+                ?flags:Cf_socket.msg_flags_t -> string -> int -> int -> int
+
+            (** Use [obj#recv ?flags buf pos len] to receive [len] octets to
+                the string [buf] starting at position [pos] from the remote
+                address previously associated with the socket using the
+                [connect] method, and optionally with the flags indicated by
+                [flags].  Returns the number of octets actually received.
+                Raises [Unix.Error] if there is an error. Raises
+                [Invalid_argument] if [pos] and [len] do not correspond to a
+                valid substring of [buf].
+            *)
+            method recv:
+                ?flags:Cf_socket.msg_flags_t -> string -> int -> int -> int
+                    
+            (** Use [obj#shutdown cmd] to shutdown either sending or receiving
+                (or both) on the socket.  Raises [Unix.Error] if there is an
+                error.
+            *)
+            method virtual shutdown: Unix.shutdown_command -> unit
+        end
+end
+
+(** The functor used to create the socket module. *)
+module Create(P: Cf_socket.P with module ST = ST): T with module P = P
+
+(*--- End of File [ cf_sock_dgram.mli ] ---*)

cf/cf_sock_dgram_p.c

+/*---------------------------------------------------------------------------*
+  C MODULE  cf_sock_dgram_p.c
+
+  Copyright (c) 2004, James H. Woodyatt
+  All rights reserved.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions
+  are met:
+
+    Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+
+    Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in
+    the documentation and/or other materials provided with the
+    distribution
+
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+  ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+  COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+  OF THE POSSIBILITY OF SUCH DAMAGE. 
+ *---------------------------------------------------------------------------*/
+
+#include "cf_sock_dgram_p.h"
+
+static value cf_sock_dgram_socktype = Val_unit;
+
+/*---
+  Lift the socket type
+  ---*/
+CAMLprim value cf_sock_dgram_socktype_lift(value unit)
+{
+    CAMLparam0();
+    CAMLreturn(cf_sock_dgram_socktype);
+}
+
+/*---
+  Initialization primitive
+  ---*/
+CAMLprim value cf_sock_dgram_init(value unit)
+{
+    register_global_root(&cf_sock_dgram_socktype);
+    cf_sock_dgram_socktype = copy_nativeint(SOCK_DGRAM);
+    return Val_unit;
+}
+
+/*--- End of File [ cf_sock_dgram_p.c ] ---*/

cf/cf_sock_dgram_p.h

+/*---------------------------------------------------------------------------*
+  C HEADER  cf_sock_dgram_p.h
+
+  Copyright (c) 2004, James H. Woodyatt
+  All rights reserved.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions
+  are met:
+
+    Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+
+    Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in
+    the documentation and/or other materials provided with the
+    distribution
+
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+  ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+  COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+  OF THE POSSIBILITY OF SUCH DAMAGE. 
+ *---------------------------------------------------------------------------*/
+
+#ifndef _CF_SOCK_DGRAM_P_H
+#define _CF_SOCK_DGRAM_P_H
+
+#include "cf_socket_p.h"
+
+#endif /* defined(_CF_SOCK_DGRAM_P_H) */
+
+/*--- End of File [ cf_sock_dgram_p.h ] ---*/

cf/cf_sock_stream.ml

 (*---------------------------------------------------------------------------*
   IMPLEMENTATION  cf_sock_stream.ml
 
-  Copyright (c) 2003, James H. Woodyatt
+  Copyright (c) 2003-2004, James H. Woodyatt
   All rights reserved.
 
   Redistribution and use in source and binary forms, with or without
             method virtual getsockname: address_t
             method virtual getpeername: address_t
 
-            method virtual send:
+            method send:
                 ?flags:Cf_socket.msg_flags_t -> string -> int -> int -> int
-            method virtual recv:
+            method recv:
                 ?flags:Cf_socket.msg_flags_t -> string -> int -> int -> int
-                    
+
             method virtual shutdown: Unix.shutdown_command -> unit
         end
 end
 module Create(P: Cf_socket.P with module ST = ST) = struct
     include Cf_sock_common.Create(P)
     
+    module S0 = Cf_socket
+    
     class initiator ?sock ?src dst =
         let src =
             match src with
             
             method virtual getsockname: address_t
 
-            method connect = Cf_socket.connect socket_ dst
+            method connect = S0.connect socket_ dst
             
             initializer
-                Cf_socket.bind socket_ src
+                S0.bind socket_ src
         end
     
     class listener ?sock src =
             
             method virtual getsockname: address_t
 
-            method listen = Cf_socket.listen socket_
+            method listen = S0.listen socket_
             
             method accept =
-                let socket, address = Cf_socket.accept socket_ in
+                let socket, address = S0.accept socket_ in
                 socket, (P.AF.of_sockaddr address)
 
             initializer
-                Cf_socket.bind socket_ (P.AF.to_sockaddr src)
+                S0.bind socket_ (P.AF.to_sockaddr src)
         end
     
     class endpoint sock =
             
             method virtual getsockname: address_t
             method virtual getpeername: address_t
-            method virtual send:
-                ?flags:Cf_socket.msg_flags_t -> string -> int -> int -> int
-            method virtual recv:
-                ?flags:Cf_socket.msg_flags_t -> string -> int -> int -> int
+            
             method virtual shutdown: Unix.shutdown_command -> unit
+            
+            method send ?(flags = S0.msg_flags_none) msg pos len =
+                S0.send socket_ msg pos len flags
+            
+            method recv ?(flags = S0.msg_flags_none) msg pos len =
+                S0.recv socket_ msg pos len flags
+            
         end
 end
 

cf/cf_sock_stream.mli

 (*---------------------------------------------------------------------------*
   INTERFACE  cf_sock_stream.mli
 
-  Copyright (c) 2003, James H. Woodyatt
+  Copyright (c) 2003-2004, James H. Woodyatt
   All rights reserved.
 
   Redistribution and use in source and binary forms, with or without
                 Raises [Invalid_argument] if [pos] and [len] do not correspond
                 to a valid substring of [buf].
             *)
-            method virtual send:
+            method send:
                 ?flags:Cf_socket.msg_flags_t -> string -> int -> int -> int
 
             (** Use [obj#recv ?flags buf pos len] to receive [len] octets to
                 Raises [Invalid_argument] if [pos] and [len] do not correspond
                 to a valid substring of [buf].
             *)
-            method virtual recv:
+            method recv:
                 ?flags:Cf_socket.msg_flags_t -> string -> int -> int -> int
                     
             (** Use [obj#shutdown cmd] to shutdown either sending or receiving

cf/cf_sock_stream_p.c

 /*---------------------------------------------------------------------------*
   C MODULE  cf_sock_stream_p.c
 
-  Copyright (c) 2003, James H. Woodyatt
+  Copyright (c) 2003-2004, James H. Woodyatt
   All rights reserved.
 
   Redistribution and use in source and binary forms, with or without

cf/cf_sock_stream_p.h

 /*---------------------------------------------------------------------------*
   C HEADER  cf_sock_stream_p.h
 
-  Copyright (c) 2003, James H. Woodyatt
+  Copyright (c) 2003-2004, James H. Woodyatt
   All rights reserved.
 
   Redistribution and use in source and binary forms, with or without
 (*---------------------------------------------------------------------------*
   IMPLEMENTATION  cf_socket.ml
 
-  Copyright (c) 2003, James H. Woodyatt
+  Copyright (c) 2003-2004, James H. Woodyatt
   All rights reserved.
 
   Redistribution and use in source and binary forms, with or without
     val protocol: protocol_t
 end
 
-type 'v untagged_sockopt_t
-type ('v,'af,'st) sockopt_t = 'v untagged_sockopt_t
+type ('v,-'af,-'st) sockopt_t
 
 external getsockopt:
     ('af,'st) t -> ('v,'af,'st) sockopt_t -> 'v = "cf_socket_getsockopt"
     SO_NOSIGPIPE
 
 external sockopt_lift:
-    sockopt_index_t -> 'a untagged_sockopt_t = "cf_socket_sockopt_lift"
+    sockopt_index_t -> ('a, 'b, 'c) sockopt_t = "cf_socket_sockopt_lift"
 
-let so_debug = sockopt_lift SO_DEBUG
-let so_reuseaddr = sockopt_lift SO_REUSEADDR
-let so_reuseport = sockopt_lift SO_REUSEPORT
-let so_keepalive = sockopt_lift SO_KEEPALIVE
-let so_dontroute = sockopt_lift SO_DONTROUTE
-let so_linger = sockopt_lift SO_LINGER
-let so_broadcast = sockopt_lift SO_BROADCAST
-let so_oobinline = sockopt_lift SO_OOBINLINE
-let so_sndbuf = sockopt_lift SO_SNDBUF
-let so_rcvbuf = sockopt_lift SO_RCVBUF
-let so_sndlowat = sockopt_lift SO_SNDLOWAT
-let so_rcvlowat = sockopt_lift SO_RCVLOWAT
-let so_sndtimeo = sockopt_lift SO_SNDTIMEO
-let so_rcvtimeo = sockopt_lift SO_RCVTIMEO
-let so_error = sockopt_lift SO_ERROR
-let so_nosigpipe = sockopt_lift SO_NOSIGPIPE
+let so_debug = Obj.magic (sockopt_lift SO_DEBUG)
+let so_reuseaddr = Obj.magic (sockopt_lift SO_REUSEADDR)
+let so_reuseport = Obj.magic (sockopt_lift SO_REUSEPORT)
+let so_keepalive = Obj.magic (sockopt_lift SO_KEEPALIVE)
+let so_dontroute = Obj.magic (sockopt_lift SO_DONTROUTE)
+let so_linger = Obj.magic (sockopt_lift SO_LINGER)
+let so_broadcast = Obj.magic (sockopt_lift SO_BROADCAST)
+let so_oobinline = Obj.magic (sockopt_lift SO_OOBINLINE)
+let so_sndbuf = Obj.magic (sockopt_lift SO_SNDBUF)
+let so_rcvbuf = Obj.magic (sockopt_lift SO_RCVBUF)
+let so_sndlowat = Obj.magic (sockopt_lift SO_SNDLOWAT)
+let so_rcvlowat = Obj.magic (sockopt_lift SO_RCVLOWAT)
+let so_sndtimeo = Obj.magic (sockopt_lift SO_SNDTIMEO)
+let so_rcvtimeo = Obj.magic (sockopt_lift SO_RCVTIMEO)
+let so_error = Obj.magic (sockopt_lift SO_ERROR)
+let so_nosigpipe = Obj.magic (sockopt_lift SO_NOSIGPIPE)
 
 (*--- End of File [ cf_socket.ml ] ---*)
 (*---------------------------------------------------------------------------*
   INTERFACE  cf_socket.mli
 
-  Copyright (c) 2003, James H. Woodyatt
+  Copyright (c) 2003-2004, James H. Woodyatt
   All rights reserved.
 
   Redistribution and use in source and binary forms, with or without