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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1471 - (download) (annotate)
Mon Mar 29 22:45:55 2004 UTC (16 years ago) by macqueen
File size: 1459 byte(s)
merged trunk from primop-branch to HEAD into primop-branch
(* unix-sock.sml
 *
 * COPYRIGHT (c) 1995 AT&T Bell Laboratories.
 *
 *)

structure UnixSock : UNIX_SOCK =
  struct
    structure SOCK = SocketImp.SOCK

    fun sockFn x = CInterface.c_function "SMLNJ-Sockets" x

    datatype unix = UNIX

    type 'a sock = (unix, 'a) Socket.sock
    type 'a stream_sock = 'a SocketImp.stream sock
    type dgram_sock = SocketImp.dgram sock

    type sock_addr = unix Socket.sock_addr

    val unixAF = Option.valOf(SocketImp.AF.fromString "UNIX")

(** We should probably do some error checking on the length of the string *)
    local
      val toUnixAddr : string -> Socket.addr = sockFn "toUnixAddr"
      val fromUnixAddr : Socket.addr -> string = sockFn "fromUnixAddr"
    in
    fun toAddr s = Socket.ADDR(toUnixAddr s)
    fun fromAddr (Socket.ADDR addr) = fromUnixAddr addr
    end

    structure Strm =
      struct
	fun socket () = GenericSock.socket (unixAF, SOCK.stream)
	fun socket' proto = GenericSock.socket' (unixAF, SOCK.stream, proto)
	fun socketPair () = GenericSock.socketPair (unixAF, SOCK.stream)
	fun socketPair' proto = GenericSock.socketPair' (unixAF, SOCK.stream, proto)
      end
    structure DGrm =
      struct
	fun socket () = GenericSock.socket (unixAF, SOCK.dgram)
	fun socket' proto = GenericSock.socket' (unixAF, SOCK.dgram, proto)
	fun socketPair () = GenericSock.socketPair (unixAF, SOCK.dgram)
	fun socketPair' proto = GenericSock.socketPair' (unixAF, SOCK.dgram, proto)
      end
  end

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