tango.net.device.Socket

License:
BSD style:

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: tango.io.device.Conduit.Conduit, tango.io.model.IConduit.ISelectable;
A wrapper around the Berkeley API to implement the IConduit abstraction and add stream-specific functionality.

deprecated void setTimeout(double t);
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();
Return the name of this device

@property Handle fileHandle();
Models a handle-oriented device.

TODO:
figure out how to avoid exposing this in the general case

@property Berkeley* native();
Return the socket wrapper

const @property size_t bufferSize();
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();
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);
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);


OutputStream copy(InputStream src, size_t max = -1);
Transfer the content of another conduit to this one. Returns the dst OutputStream, or throws IOException on failure.

Does optimized transfers

package final bool wait(bool reading);
Manage socket IO under a timeout

final void error();
Throw an IOException noting the last error

Socket asyncCopy(Handle file);


class ServerSocket: tango.net.device.Socket.Socket;


this(uint port, int backlog = 32, bool reuse = false);


this(Address addr, int backlog = 32, bool reuse = false);


string toString();
Return the name of this device

Socket accept(Socket recipient = null);



Page generated by Ddoc. Copyright (c) 2004 Kris Bell. All rights reserved