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/SMLNJ/src/compiler/PervEnv/Sockets/inet-sock.sml
ViewVC logotype

View of /sml/branches/SMLNJ/src/compiler/PervEnv/Sockets/inet-sock.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 249 - (download) (annotate)
Sat Apr 17 18:57:03 1999 UTC (20 years, 4 months ago) by monnier
File size: 1589 byte(s)
version 110.16
(* inet-sock.sml
 *
 * COPYRIGHT (c) 1995 AT&T Bell Laboratories.
 *
 *)

structure INetSock : INET_SOCK =
  struct
    structure SOCK = Socket.SOCK

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

    datatype inet = INET

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

    type sock_addr = inet Socket.sock_addr

    val inetAF = Option.valOf(Socket.AF.fromString "INET")

    local
      val toInetAddr : (PreSock.addr * int) -> PreSock.addr = sockFn "toInetAddr"
      val fromInetAddr : PreSock.addr -> (PreSock.addr * int) = sockFn "fromInetAddr"
      val inetAny  : int -> PreSock.addr = sockFn "inetany"
    in
    fun toAddr (PreSock.INADDR a, port) = PreSock.ADDR(toInetAddr(a, port))
    fun fromAddr (PreSock.ADDR addr) = let
	  val (a, port) = fromInetAddr addr
	  in
	    (PreSock.INADDR a, port)
	  end
    fun any port = PreSock.ADDR(inetAny port)
    end

    structure UDP =
      struct
	fun socket () = GenericSock.socket (inetAF, SOCK.dgram)
	fun socket' proto = GenericSock.socket' (inetAF, SOCK.dgram, proto)
      end

    structure TCP =
      struct
	fun socket () = GenericSock.socket (inetAF, SOCK.stream)
	fun socket' proto = GenericSock.socket' (inetAF, SOCK.stream, proto)
      (* tcp control options *)
	local
	  val ctlDELAY : (int * bool option) -> bool = sockFn "ctlNODELAY"
	in
	fun getNODELAY (PreSock.SOCK fd) = ctlDELAY(fd, NONE)
	fun setNODELAY (PreSock.SOCK fd, flg) = ignore(ctlDELAY(fd, SOME flg))
	end (* local *)
      end
  end

(*
 * $Log$
 *)

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