vibe.d beta banner
get vibe.d
0.10.1

Asynchronous I/O that doesn’t get in your way, written in D

Function EventDriverSockets.read

Reads data from a stream socket.

abstract void read (
  StreamSocketFD socket,
  ubyte[] buffer,
  IOMode mode,
  nothrow @safe void delegate(StreamSocketFD, IOStatus, ulong) on_read_finish
) nothrow @safe;

Note that only a single read operation is allowed at once. The caller needs to make sure that either on_read_finish got called, or cancelRead was called before issuing the next call to read. However, concurrent writes are legal.

Waiting for data availability

With the special combination of a zero-length buffer and mode set to either IOMode.once or IOMode.all, this function will wait until data is available on the socket without reading anything.

Note that in this case the IOStatus parameter of the callback will not reliably reflect a passive connection close. It is necessary to actually read some data to make sure this case is detected.

Authors
Copyright
License