tango.net.device.Socket

License:

BSD style: see license.txt

Version:

Mar 2004: Initial release

Version:

Jan 2005: RedShodan patch for timeout query

Version:

Dec 2006: Outback release

Version:

Apr 2009: revised for asynchronous IO

Author:

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(Address addr)
Create an Internet Socket with the provided characteristics
this(AddressFamily family, SocketType type, ProtocolType protocol)
Create an Internet socket
string toString() [override]
Return the name of this device
Handle fileHandle() [@property]
Models a handle-oriented device.

TODO:

figure out how to avoid exposing this in the general case
Berkeley* native() [@property]
Return the socket wrapper
size_t bufferSize() [@property, override, const]
Return a preferred size for buffering conduit I/O
Socket connect(const(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(const(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
Socket asyncCopy(Handle file)
class ServerSocket : Socket
this(uint port, int backlog = 32, bool reuse = false)
this(Address addr, int backlog = 32, bool reuse = false)
string toString() [override]
Return the name of this device
Socket accept(Socket recipient = null)