splat

Splat: the socket platform with the lame name. It's full of puns, but it runs! Download Splat. Version 0.7. For both Phobos and Tango; tested with Phobos and Tango 0.99.2.

void run();
Run the event loop; wait for timer and socket events. Exceptions that occur in event callbacks break out of run.

void exitLoop();
Causes run() to return as soon as it can.

class Timer;
Timers; alarms (timeout events) depend on run().

final void interval(uint iv);
final uint interval();
Property:
get and set the timer interval in milliseconds.

final void start();
Start this timer.

final void stop();
Stop this timer.

void onAlarm();
Override to be notified when the time expires. Alarms continue until stop().

this();
this(void delegate(Timer) dg);
Construct a timer; can take a delegate that is called back automatically on an alarm.

enum EventType;
Socket event flags.

NONE


READ
WRITE
ACCEPT
CONNECT
CLOSE


alias RegisterEventCallback;
Callback type for socket events.

Params:
sock the socket
type which event; will be only one of the event flags.
err an error code, or 0 if successful.

class AsyncSocket: std.socket.Socket;
Asynchronous sockets; socket events depend on run(). Mostly the same as std.socket.Socket.

void event(EventType events, void delegate(Socket sock, EventType type, int err) callback);
Registers a callback for specified socket events. One or more type flags may be used, or NONE to cancel all. Calling this twice on the same socket cancels out previously registered events for the socket.

class AsyncTcpSocket: splat.AsyncSocket;
Asynchronous TCP socket shortcut.

this(AddressFamily family);
this();
this(EventType events, void delegate(Socket sock, EventType type, int err) eventCallback);
this(Address connectTo, EventType events, void delegate(Socket sock, EventType type, int err) eventCallback);


class AsyncUdpSocket: splat.AsyncSocket;
Asynchronous UDP socket shortcut.

this(AddressFamily family);
this();
this(EventType events, void delegate(Socket sock, EventType type, int err) eventCallback);


alias GetHostCallback;
Callback type for host resolve event.

Params:
inetHost the InternetHost/NetHost of the resolved host, or null.
err an error code, or 0 if successful; if 0, inetHost will be null.

class GetHost;
Returned from asyncGetHost functions.

void cancel();
Cancel the get-host operation.

GetHost asyncGetHostByName(char[] name, void delegate(InternetHost inetHost, int err) callback);
Asynchronously resolve host information from a hostname; the callback depends on run().

GetHost asyncGetHostByAddr(uint addr, void delegate(InternetHost inetHost, int err) callback);
GetHost asyncGetHostByAddr(char[] addr, void delegate(InternetHost inetHost, int err) callback);
Asynchronously resolve host information from an IPv4 address; the callback depends on run().

class SocketQueue;
Buffering socket I/O.

this(Socket sock);


final Socket socket();
Property:
get the socket of this queue.

void reset();
Resets the buffers.

void[] peek();
void[] peek(uint len);
Peek at some or all of the received data but leave it in the queue. May return less than requested.

void[] receive();
void[] receive(uint len);
Returns:
some or all of the received data and removes this amount from the queue. May return less than requested.

void send(void[] buf);
Add data to the queue and send it over this socket.

uint sendBytes();
Property:
get the number of bytes in send buffer.

uint receiveBytes();
Property:
get the number of bytes in recv buffer.

void readEvent();
Call on a read event so that incoming data may be buffered.

void writeEvent();
Call on a write event so that buffered outgoing data may be sent.

void event(Socket _sock, EventType type, int err);
Shortcut function for AsyncSocket. Automatically calls readEvent and writeEvent as needed. Same signature as RegisterEventCallback for simplicity.

uint getNumberOfAsyncSockets();
Returns the number of asynchronous sockets waiting for events.

uint getNumberOfTimers();
Returns the number of active timers.


Page generated by Ddoc.