[MLton-commit] r6945
Vesa Karvonen
vesak at mlton.org
Fri Oct 17 01:43:24 PDT 2008
Renamed maxAccepts -> numAccepts for clarity.
Also changed tcpNoDelay to default to false.
----------------------------------------------------------------------
U mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/detail/server.sml
U mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/server.sml
U mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/public/server/server.sig
----------------------------------------------------------------------
Modified: mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/detail/server.sml
===================================================================
--- mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/detail/server.sml 2008-10-16 21:17:49 UTC (rev 6944)
+++ mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/detail/server.sml 2008-10-17 08:43:14 UTC (rev 6945)
@@ -47,7 +47,7 @@
datatype t = IN
of {name : String.t
, port : Int.t
- , maxAccepts : Int.t Option.t
+ , numAccepts : Int.t Option.t
, tcpNoDelay : Bool.t
, serverError : Exn.t Effect.t
, closed : Unit.t Effect.t
@@ -69,8 +69,8 @@
val default : t =
IN {name = "127.0.0.1"
, port = 45678
- , maxAccepts = NONE
- , tcpNoDelay = true
+ , numAccepts = NONE
+ , tcpNoDelay = false
, serverError = ignore
, closed = ignore
, accept = const true
@@ -84,7 +84,7 @@
OPT {set = fn value =>
fn IN {name
, port
- , maxAccepts
+ , numAccepts
, tcpNoDelay
, serverError
, closed
@@ -97,7 +97,7 @@
val opts =
{name = ref name
, port = ref port
- , maxAccepts = ref maxAccepts
+ , numAccepts = ref numAccepts
, tcpNoDelay = ref tcpNoDelay
, serverError = ref serverError
, closed = ref closed
@@ -112,7 +112,7 @@
set opts := value
; IN {name = get #name
, port = get #port
- , maxAccepts = get #maxAccepts
+ , numAccepts = get #numAccepts
, tcpNoDelay = get #tcpNoDelay
, serverError = get #serverError
, closed = get #closed
@@ -127,7 +127,7 @@
val name = mk #name #name
val port = mk #port #port
- val maxAccepts = mk #maxAccepts #maxAccepts
+ val numAccepts = mk #numAccepts #numAccepts
val tcpNoDelay = mk #tcpNoDelay #tcpNoDelay
val serverError = mk #serverError #serverError
val closed = mk #closed #closed
@@ -145,7 +145,7 @@
fun start entries
(Opts.IN {name
, port
- , maxAccepts
+ , numAccepts
, tcpNoDelay
, serverError
, closed
@@ -178,8 +178,8 @@
else (connected {addr = addr}
; serve addr)))
- fun listen maxAccepts =
- if SOME 0 = maxAccepts
+ fun listen numAccepts =
+ if SOME 0 = numAccepts
then return ()
else SocketEvents.sockEvt OS.IO.pollIn >>= (fn socket =>
case Socket.acceptNB socket
@@ -187,7 +187,7 @@
| SOME (socket, addr) =>
(if not (accept {addr = addr})
then (Socket.close socket
- ; listen maxAccepts)
+ ; listen numAccepts)
else (INetSock.TCP.setNODELAY (socket, tcpNoDelay)
; (when (negotiate addr socket))
(fn r =>
@@ -198,7 +198,7 @@
| INL e =>
protocolError {addr = addr, error = e}
; disconnected {addr = addr}))
- ; listen (Option.map (fn n => n-1) maxAccepts))))
+ ; listen (Option.map (fn n => n-1) numAccepts))))
val socket = INetSock.TCP.socket ()
in
@@ -210,7 +210,7 @@
port))
; Socket.listen (socket, 16))
handle e => (Socket.close socket ; raise e)
- ; (when (listen maxAccepts socket))
+ ; (when (listen numAccepts socket))
(fn r =>
(Socket.close socket
; case r
Modified: mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/server.sml
===================================================================
--- mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/server.sml 2008-10-16 21:17:49 UTC (rev 6944)
+++ mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/server.sml 2008-10-17 08:43:14 UTC (rev 6945)
@@ -24,7 +24,7 @@
open TCP.Opts
in
default
- & maxAccepts := SOME 1
+ & numAccepts := SOME 1
end
; run ()
end
Modified: mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/public/server/server.sig
===================================================================
--- mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/public/server/server.sig 2008-10-16 21:17:49 UTC (rev 6944)
+++ mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/public/server/server.sig 2008-10-17 08:43:14 UTC (rev 6945)
@@ -35,7 +35,7 @@
* Example:
*
*> default & port := 4321
- *> & maxAccepts := SOME 1
+ *> & numAccepts := SOME 1
*)
val & : t * ('a opt * 'a) -> t
@@ -47,13 +47,18 @@
(** default: {"127.0.0.1"} *)
val port : Int.t opt
- (** default: 45678 *)
+ (** default: {45678} *)
- val maxAccepts : Int.t Option.t opt
- (** default: {NONE} *)
+ val numAccepts : Int.t Option.t opt
+ (**
+ * Optional number of connections to accept after which the
+ * listener port is closed automatically.
+ *
+ * default: {NONE}
+ *)
val tcpNoDelay : Bool.t opt
- (** default: {true} *)
+ (** default: {false} *)
(** == Server Events == *)
More information about the MLton-commit
mailing list