FastCGIServer
public class FastCGIServer : Server
A server that listens for incoming HTTP requests that are sent using the FastCGI protocol.
-
Declaration
Swift
public typealias ServerType = FastCGIServer
-
The
ServerDelegate
to handle incoming requests.Declaration
Swift
public var delegate: ServerDelegate?
-
Port number for listening for new connections
Declaration
Swift
public private(set) var port: Int? { get }
-
The address of a network interface to listen on, for example “localhost”. The default is nil, which listens for connections on all interfaces.
Declaration
Swift
public private(set) var address: String? { get }
-
A server state.
Declaration
Swift
public private(set) var state: ServerState { get }
-
Whether or not this server allows port reuse (default: disallowed)
Declaration
Swift
public var allowPortReuse: Bool
-
Undocumented
Declaration
Swift
public init()
-
Listens for connections on a socket
Declaration
Swift
public func listen(on port: Int, address: String? = nil) throws
Parameters
on
port number for new connections
address
The address of the network interface to listen on. Defaults to nil, which means this server will listen on all interfaces.
-
Static method to create a new
FastCGIServer
and have it listen for conenctionsDeclaration
Swift
public static func listen(on port: Int, address: String? = nil, delegate: ServerDelegate?) throws -> FastCGIServer
Parameters
on
port number for accepting new connections
address
The address of the network interface to listen on. Defaults to nil, which means this server will listen on all interfaces.
delegate
the delegate handler for FastCGI/HTTP connections
Return Value
a new
FastCGIServer
instance -
Listens for connections on a socket
Declaration
Swift
@available(*, deprecated, message: "use 'listen(on:﹚ throws' with 'server.failed(callback:﹚' instead") public func listen(port: Int, errorHandler: ((Swift.Error) -> Void)? = nil)
Parameters
port
port number for new connections (ex. 9000)
errorHandler
optional callback for error handling
-
Static method to create a new
FastCGIServer
and have it listen for conenctionsDeclaration
Swift
@available(*, deprecated, message: "use 'listen(on:delegate:﹚ throws' with 'server.failed(callback:﹚' instead") public static func listen(port: Int, delegate: ServerDelegate, errorHandler: ((Swift.Error) -> Void)? = nil) -> FastCGIServer
Parameters
port
port number for accepting new connections
delegate
the delegate handler for FastCGI/HTTP connections
errorHandler
optional callback for error handling
Return Value
a new
FastCGIServer
instance -
Stop listening for new connections.
Declaration
Swift
public func stop()
-
Add a new listener for server being started
Declaration
Swift
@discardableResult public func started(callback: @escaping () -> Void) -> Self
Parameters
callback
The listener callback that will run on server successfull start-up
Return Value
a
FastCGIServer
instance -
Add a new listener for server being stopped
Declaration
Swift
@discardableResult public func stopped(callback: @escaping () -> Void) -> Self
Parameters
callback
The listener callback that will run when server stops
Return Value
a
FastCGIServer
instance -
Add a new listener for server throwing an error
Declaration
Swift
@discardableResult public func failed(callback: @escaping (Swift.Error) -> Void) -> Self
Parameters
callback
The listener callback that will run when server throws an error
Return Value
a
FastCGIServer
instance -
Add a new listener for when listenSocket.acceptClientConnection throws an error
Declaration
Swift
@discardableResult public func clientConnectionFailed(callback: @escaping (Swift.Error) -> Void) -> Self
Parameters
callback
The listener callback that will run
Return Value
a Server instance