BSD style: see
license.txt
Mar 2004: Initial release
Jan 2005: RedShodan patch for timeout query
Dec 2006: Outback release
Apr 2009: revised for asynchronous IO
Kris
- class Socket : Conduit, ISelectable ¶#
-
A wrapper around the Berkeley API to implement the IConduit
abstraction and add stream-specific functionality.
- void setTimeout(double t) [deprecated] ¶#
-
see super.timeout(int)
- this() ¶#
-
Create a streaming Internet socket
- this(AddressFamily family, SocketType type, ProtocolType protocol) ¶#
-
Create an Internet socket
- char[] toString() [override] ¶#
-
Return the name of this device
- Handle fileHandle() ¶#
-
Models a handle-oriented device.
figure out how to avoid exposing this in the general
case
- Berkeley* native() ¶#
-
Return the socket wrapper
- size_t bufferSize() [override] ¶#
-
Return a preferred size for buffering conduit I/O
- Socket connect(char[] address, uint port) ¶#
-
Connect to the provided endpoint
- Socket connect(Address addr) ¶#
-
Connect to the provided endpoint
- Socket bind(Address address) ¶#
-
Bind this socket. This is typically used to configure a
listening socket (such as a server or multicast socket).
The address given should describe a local adapter, or
specify the port alone (ADDR_ANY) to have the OS assign
a local adapter address.
- Socket shutdown() ¶#
-
Inform other end of a connected socket that we're no longer
available. In general, this should be invoked before close()
The shutdown function shuts down the connection of the socket:
- stops receiving data for this socket. If further data
arrives, it is rejected.
- stops trying to transmit data from this socket. Also
discards any data waiting to be sent. Stop looking for
acknowledgement of data already sent; don't retransmit
if any data is lost.
- void detach() [override] ¶#
-
Release this Socket
Note that one should always disconnect a Socket under
normal conditions, and generally invoke shutdown on all
connected sockets beforehand
- size_t read(void[] dst) [override] ¶#
-
Read content from the socket. Note that the operation
may timeout if method setTimeout() has been invoked with
a non-zero value.
Returns the number of bytes read from the socket, or
IConduit.Eof where there's no more content available.
- size_t write(void[] src) [override] ¶#
-
- OutputStream copy(InputStream src, size_t max = -1) [override] ¶#
-
Transfer the content of another conduit to this one. Returns
the dst OutputStream, or throws IOException on failure.
Does optimized transfers
- bool wait(bool reading) [package, final] ¶#
-
Manage socket IO under a timeout
- void error() [final] ¶#
-
Throw an IOException noting the last error
- void asyncConnect(Address addr) [private] ¶#
-
Connect to the provided endpoint
- void asyncCopy(Handle handle) [private] ¶#
-
- size_t asyncRead(void[] dst) [private] ¶#
-
Read a chunk of bytes from the file into the provided
array. Returns the number of bytes read, or Eof where
there is no further data.
Operates asynchronously where the hosting thread is
configured in that manner.
- size_t asyncWrite(void[] src) [private] ¶#
-
Write a chunk of bytes to the file from the provided
array. Returns the number of bytes written, or Eof if
the output is no longer available.
Operates asynchronously where the hosting thread is
configured in that manner.
- size_t wait(scheduler.Type type, uint bytes = 0) [private] ¶#
-
- void patch(socket_t dst, uint how, socket_t* src = null) [private, static] ¶#
-
- class ServerSocket : Socket ¶#
-
- this(uint port, int backlog = 32, bool reuse = false) ¶#
-
- this(Address addr, int backlog = 32, bool reuse = false) ¶#
-
- char[] toString() [override] ¶#
-
Return the name of this device
- Socket accept(Socket recipient = null) ¶#
-
- void asyncAccept(Socket recipient) [private] ¶#
-