Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /sml/branches/primop-branch/src/system/Basis/Implementation/Sockets/unix-generic-sock.sml
ViewVC logotype

Diff of /sml/branches/primop-branch/src/system/Basis/Implementation/Sockets/unix-generic-sock.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1470, Mon Mar 29 22:45:55 2004 UTC revision 1471, Mon Mar 29 22:45:55 2004 UTC
# Line 6  Line 6 
6    
7  structure GenericSock : GENERIC_SOCK =  structure GenericSock : GENERIC_SOCK =
8    struct    struct
9      structure PS = PreSock      structure S = Socket
10    
11      fun sockFn x = CInterface.c_function "SMLNJ-Sockets" x      fun sockFn x = CInterface.c_function "SMLNJ-Sockets" x
12    
13    (* returns a list of the supported address families; this should include      val c_socket        : (int * int * int) -> S.sockFD
    * at least:  Socket.AF.inet.  
    *)  
     fun addressFamilies () = raise Fail "GenericSock.addressFamilies"  
   
   (* returns a list of the supported socket types; this should include at  
    * least:  Socket.SOCK.stream and Socket.SOCK.dgram.  
    *)  
     fun socketTypes () = raise Fail "GenericSock.socketTypes"  
   
     val c_socket        : (int * int * int) -> PS.socket  
14            = sockFn "socket"            = sockFn "socket"
15      val c_socketPair    : (int * int * int) -> (PS.socket * PS.socket)      val c_socketPair    : (int * int * int) -> (S.sockFD * S.sockFD)
16            = sockFn "socketPair"            = sockFn "socketPair"
17    
18        fun fd2sock fd = S.SOCK { fd = fd, nb = ref false }
19    
20    (* create sockets using default protocol *)    (* create sockets using default protocol *)
21      fun socket (PS.AF(af, _), PS.SOCKTY(ty, _)) =      fun socket (S.AF.AF(af, _), S.SOCK.SOCKTY(ty, _)) =
22            PS.SOCK(c_socket (af, ty, 0))            fd2sock (c_socket (af, ty, 0))
23      fun socketPair (PS.AF(af, _), PS.SOCKTY(ty, _)) = let      fun socketPair (S.AF.AF(af, _), S.SOCK.SOCKTY(ty, _)) = let
24            val (s1, s2) = c_socketPair (af, ty, 0)            val (s1, s2) = c_socketPair (af, ty, 0)
25            in            in
26              (PS.SOCK s1, PS.SOCK s2)              (fd2sock s1, fd2sock s2)
27            end            end
28    
29    (* create sockets using the specified protocol *)    (* create sockets using the specified protocol *)
30      fun socket' (PS.AF(af, _), PS.SOCKTY(ty, _), prot) =      fun socket' (S.AF.AF(af, _), S.SOCK.SOCKTY(ty, _), prot) =
31            PS.SOCK(c_socket (af, ty, prot))            fd2sock (c_socket (af, ty, prot))
32      fun socketPair' (PS.AF(af, _), PS.SOCKTY(ty, _), prot) = let      fun socketPair' (S.AF.AF(af, _), S.SOCK.SOCKTY(ty, _), prot) = let
33            val (s1, s2) = c_socketPair (af, ty, prot)            val (s1, s2) = c_socketPair (af, ty, prot)
34            in            in
35              (PS.SOCK s1, PS.SOCK s2)              (fd2sock s1, fd2sock s2)
36            end            end
37    
38    end    end
   

Legend:
Removed from v.1470  
changed lines
  Added in v.1471

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0