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/win32-generic-sock.sml
ViewVC logotype

Diff of /sml/branches/primop-branch/src/system/Basis/Implementation/Sockets/win32-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 7  Line 7 
7    
8  structure GenericSock : GENERIC_SOCK =  structure GenericSock : GENERIC_SOCK =
9    struct    struct
10      structure PS = PreSock      structure S = Socket
11    
12      fun sockFn x = CInterface.c_function "SMLNJ-Sockets" x      fun sockFn x = CInterface.c_function "SMLNJ-Sockets" x
13    
14    (* 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  
15            = sockFn "socket"            = sockFn "socket"
16  (*    val c_socketPair  : (int * int * int) -> (PS.socket * PS.socket)  (*    val c_socketPair  : (int * int * int) -> (S.sockFD * S.sockFD)
17            = sockFn "socketPair"*)            = sockFn "socketPair"*)
18      fun c_socketPair _ = raise Fail "socketPair not implemented by WinSock"      fun c_socketPair _ = raise Fail "socketPair not implemented by WinSock"
19    
20        fun fd2sock fd = S.SOCK { fd = fd, nb = ref false }
21    
22    (* create sockets using default protocol *)    (* create sockets using default protocol *)
23      fun socket (PS.AF(af, _), PS.SOCKTY(ty, _)) =      fun socket (S.AF.AF(af, _), S.SOCK.SOCKTY(ty, _)) =
24            PS.SOCK(c_socket (af, ty, 0))            fd2sock (c_socket (af, ty, 0))
25      fun socketPair (PS.AF(af, _), PS.SOCKTY(ty, _)) = let      fun socketPair (S.AF.AF(af, _), S.SOCK.SOCKTY(ty, _)) = let
26            val (s1, s2) = c_socketPair (af, ty, 0)            val (s1, s2) = c_socketPair (af, ty, 0)
27            in            in
28              (PS.SOCK s1, PS.SOCK s2)              (fd2sock s1, fd2sock s2)
29            end            end
30    
31    (* create sockets using the specified protocol *)    (* create sockets using the specified protocol *)
32      fun socket' (PS.AF(af, _), PS.SOCKTY(ty, _), prot) =      fun socket' (S.AF.AF(af, _), S.SOCK.SOCKTY(ty, _), prot) =
33            PS.SOCK(c_socket (af, ty, prot))            fd2sock (c_socket (af, ty, prot))
34      fun socketPair' (PS.AF(af, _), PS.SOCKTY(ty, _), prot) = let      fun socketPair' (S.AF.AF(af, _), S.SOCK.SOCKTY(ty, _), prot) = let
35            val (s1, s2) = c_socketPair (af, ty, prot)            val (s1, s2) = c_socketPair (af, ty, prot)
36            in            in
37              (PS.SOCK s1, PS.SOCK s2)              (fd2sock s1, fd2sock s2)
38            end            end
   
39    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