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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

structure GenericSock : GENERIC_SOCK =
  struct
    structure S = Socket

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

    val c_socket	: (int * int * int) -> S.sockFD
	  = sockFn "socket"
    val c_socketPair	: (int * int * int) -> (S.sockFD * S.sockFD)
	  = sockFn "socketPair"

    fun fd2sock fd = S.SOCK { fd = fd, nb = ref false }

  (* create sockets using default protocol *)
    fun socket (S.AF.AF(af, _), S.SOCK.SOCKTY(ty, _)) =
	  fd2sock (c_socket (af, ty, 0))
    fun socketPair (S.AF.AF(af, _), S.SOCK.SOCKTY(ty, _)) = let
	  val (s1, s2) = c_socketPair (af, ty, 0)
	  in
	    (fd2sock s1, fd2sock s2)
	  end

  (* create sockets using the specified protocol *)
    fun socket' (S.AF.AF(af, _), S.SOCK.SOCKTY(ty, _), prot) =
	  fd2sock (c_socket (af, ty, prot))
    fun socketPair' (S.AF.AF(af, _), S.SOCK.SOCKTY(ty, _), prot) = let
	  val (s1, s2) = c_socketPair (af, ty, prot)
	  in
	    (fd2sock s1, fd2sock s2)
	  end

  end

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