► |  | Web Server: HTTP Server

1 | Dispatching Server
2 | Dispatchers
3 | Launching Servers
4 | Web Servers
5 | Internal APIs
6 | Troubleshooting and Tips
| Index

▼ | 5 | Internal APIs

5.1 | Timers
5.2 | Connection Manager
5.3 | Serializable Closures
5.4 | Cache Table
5.5 | MIME Types
5.6 | Serialization Utilities
5.7 | URL Param
5.8 | GZip
5.9 | Miscellaneous Utilities

On this page:

connection
connection-manager?
start-connection-manager
new-connection
kill-connection!
adjust-connection-timeout!
reset-connection-timeout!

top ← prev up next →

#### 5.2`` Connection Manager

(require web-server/private/connection-manager)
| package: web-server-lib

This module provides functionality for managing pairs of input and output ports. We have plans to allow a number of different strategies for doing this.

> > struct

> > (struct |  | connection (timer i-port o-port custodian close?)

> #:extra-constructor-name make-connection)
> timer : timer?
> i-port : input-port?
> o-port : output-port?
> custodian : custodian?
> close? : boolean?

A connection is a pair of ports (i-port and o-port) that is ready to close after the current job if close? is #t. Resources associated with the connection should be allocated under custodian. The connection will last until timer triggers.
Construct connection instances using new-connection, which cooperates with connection managers. Constructing connections by other means (e.g. make-connection or struct-copy) may have undesirable consequences, such as circumventing safety limits.

Changed in version 1.6 of package web-server-lib: Deprecate construction other than via new-connection.

> > procedure

> > (connection-manager? v) → boolean?

> v : any/c

> > procedure

> > (start-connection-manager [#:safety-limits safety-limits])

> → connection-manager?

> | safety-limits |  | : |  | safety-limits?
> |  |  | = |  | (make-unlimited-safety-limits)

A connection manager is an opaque value, recognized by the predicate connection-manager?, which cooperates with new-connection to control the creation and behavior of connection instances. It encapsulates a timer manager (see Timers), safety limits policies, and other internal data. Use start-connection-manager to create a connection manager.
Note that, if the safety-limits argument is not given, the default safety limits value offers minimal protection against malicious or misbehaving clients and servlets: see make-unlimited-safety-limits. Most programs should not not use start-connection-manager or new-connection directly: higher-level interfaces, such as dispatch-server-with-connect@ and serve, incorporate connection management and provide more protections by default. The permissive default safety limits of start-connection-manager maximize backwards-compatability for low-level programs that use these functions directly. See the safety limits compatability note for more information.

Changed in version 1.6 of package web-server-lib: Added safety-limits argument.

> > procedure

> > (new-connection cm i-port o-port cust close?) → connection?

> cm : connection-manager?
> i-port : input-port?
> o-port : output-port?
> cust : custodian?
> close? : boolean?

> (new-connection |  | cm |  |  |  |
> |  | timeout |  |  |  |
> |  | i-port |  |  |  |
> |  | o-port |  |  |  |
> |  | cust |  |  |  |
> |  | close?) |  | → |  | connection?

> cm : connection-manager?
> timeout : number?
> i-port : input-port?
> o-port : output-port?
> cust : custodian?
> close? : boolean?

Cooperates with the connection manager cm to construct a new connection instance. The connection is created with a timer that effectively calls kill-connection!. The initial timeout is determened by the safety limits encapsulated in cm.
The six-argument form with a timeout argument is provided for backwards compatability. In that case, timeout is used for the initial value of the connection’s timer, regardless of cm’s safety limits. Other aspects of the safety limits still apply to the resulting connection.

Changed in version 1.6 of package web-server-lib: Added five-argument form using cm’s safety limits instead of a timeout argument.

> > procedure

> > (kill-connection! c) → any

> c : connection?

Closes the ports associated with c, kills the timer, and shuts down the custodian.

> > procedure

> > (adjust-connection-timeout! c t) → any

> c : connection?
> t : number?

Calls increment-timer! with the timer behind c with t.

> > procedure

> > (reset-connection-timeout! c t) → any

> c : connection?
> t : number?

Calls reset-timer! with the timer behind c with t.

Added in version 1.6 of package web-server-lib.

top ← prev up next →