The OpenD Programming Language

FiberManager

The FiberManager is responsible for running your socket event loop and dispatching events to your fibers. It is your main point of interaction with this library.

Generally, a FiberManager will exist in your main function and take over that thread when you call run. You construct one, set up your listeners, etc., then call run and let it do its thing.

Constructors

this
this(size_t defaultFiberStackSize)

Members

Functions

bindDatagram
Socket bindDatagram(Address address)

Only valid from inside a worker fiber, see makeFiber.

bindUdp4
Socket bindUdp4(string address, ushort port)
Socket bindUdp4(ushort port)
bindUdp6
Socket bindUdp6(string address, ushort port)
Socket bindUdp6(ushort port)

These are convenience functions that forward to bindDatagram.

connectStream
Socket connectStream(Address address)

Connects a streaming socket to the given address that will yield to this FiberManager instead of blocking.

connectTcp4
Socket connectTcp4(string address, ushort port)
connectTcp6
Socket connectTcp6(string address, ushort port)
connectUnix
Socket connectUnix(string path)

Convenience functions that forward to connectStream for the given protocol. They connect, send, and receive in an async manner, but do not create their own fibers - you must already be in one when you call this function.

listenStream
Socket listenStream(Address addr, void delegate(Socket) connectionHandler, int backlog)

Core listen function for streaming connection-oriented sockets (TCP, etc.)

listenTcp4
Socket listenTcp4(ushort port, void delegate(Socket) connectionHandler, int backlog)
Socket listenTcp4(string address, ushort port, void delegate(Socket) connectionHandler, int backlog)

Convenience functions for creating listening sockets. These are trivial forwarders to listenStream, constructing the appropriate std.socket.Address object for you. Note the address lookup does NOT at this time use the fiber io and may thus block your thread.

listenTcp6
Socket listenTcp6(ushort port, void delegate(Socket) connectionHandler, int backlog)
Socket listenTcp6(string address, ushort port, void delegate(Socket) connectionHandler, int backlog)
listenUnix
Socket listenUnix(string path, void delegate(Socket) connectionHandler, int backlog)

Convenience functions for creating listening sockets. These are trivial forwarders to listenStream, constructing the appropriate std.socket.Address object for you. Note the address lookup does NOT at this time use the fiber io and may thus block your thread.

makeFiber
Fiber makeFiber(void delegate() fn)

Convenience function to make a worker fiber based on the manager's configuration.

run
void run()

Runs the program and manages the fibers and connections for you, calling the appropriate functions when new events arrive.

Meta