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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1471 - (view) (download)

1 : monnier 416 (* unix-sock.sml
2 :     *
3 :     * COPYRIGHT (c) 1995 AT&T Bell Laboratories.
4 :     *
5 :     *)
6 :    
7 :     structure UnixSock : UNIX_SOCK =
8 :     struct
9 : macqueen 1471 structure SOCK = SocketImp.SOCK
10 : monnier 416
11 :     fun sockFn x = CInterface.c_function "SMLNJ-Sockets" x
12 :    
13 :     datatype unix = UNIX
14 :    
15 :     type 'a sock = (unix, 'a) Socket.sock
16 : macqueen 1471 type 'a stream_sock = 'a SocketImp.stream sock
17 :     type dgram_sock = SocketImp.dgram sock
18 : monnier 416
19 :     type sock_addr = unix Socket.sock_addr
20 :    
21 : macqueen 1471 val unixAF = Option.valOf(SocketImp.AF.fromString "UNIX")
22 : monnier 416
23 :     (** We should probably do some error checking on the length of the string *)
24 :     local
25 : macqueen 1471 val toUnixAddr : string -> Socket.addr = sockFn "toUnixAddr"
26 :     val fromUnixAddr : Socket.addr -> string = sockFn "fromUnixAddr"
27 : monnier 416 in
28 : macqueen 1471 fun toAddr s = Socket.ADDR(toUnixAddr s)
29 :     fun fromAddr (Socket.ADDR addr) = fromUnixAddr addr
30 : monnier 416 end
31 :    
32 :     structure Strm =
33 :     struct
34 :     fun socket () = GenericSock.socket (unixAF, SOCK.stream)
35 :     fun socket' proto = GenericSock.socket' (unixAF, SOCK.stream, proto)
36 :     fun socketPair () = GenericSock.socketPair (unixAF, SOCK.stream)
37 :     fun socketPair' proto = GenericSock.socketPair' (unixAF, SOCK.stream, proto)
38 :     end
39 :     structure DGrm =
40 :     struct
41 :     fun socket () = GenericSock.socket (unixAF, SOCK.dgram)
42 :     fun socket' proto = GenericSock.socket' (unixAF, SOCK.dgram, proto)
43 :     fun socketPair () = GenericSock.socketPair (unixAF, SOCK.dgram)
44 :     fun socketPair' proto = GenericSock.socketPair' (unixAF, SOCK.dgram, proto)
45 :     end
46 :     end

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