Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

SocketConduit Class Reference

Inheritance diagram for SocketConduit:

Socket ISocketReader List of all members.

Public Types

typedef Socket read read

Public Member Functions

deprecated this ()
 this (bool textual)
void close ()
uint read (IBuffer target)
bool isTextual ()

Static Public Member Functions

static SocketConduit create (socket_t handle)

Private Member Functions

 this (socket_t handle)
 this (AddressFamily af, Type type, Protocol protocol)
 this (ConduitStyle.Bits style, bool seekable)
uint reader (void[] dst)
uint writer (void[] src)
uint bufferSize ()
void setTimeout (uint us)
bool hadTimeout ()
void set (socket_t sock)
void reset ()
void create (AddressFamily af, Type type, Protocol protocol)
socket_t handle ()
char[] toString ()
bit blocking ()
void blocking (bit byes)
AddressFamily addressFamily ()
bit isAlive ()
void bind (Address addr)
void connect (Address to)
void listen (int backlog)
Socket createSocket (socket_t handle)
Socket accept ()
void shutdown ()
void shutdown (Shutdown how)
void setLingerPeriod (int period)
void setAddressReuse (bool enabled)
bool setGroup (InternetAddress address, Option option)
Address remoteAddress ()
Address localAddress ()
int send (void[] buf, Flags flags=Flags.NONE)
int sendTo (void[] buf, Flags flags, Address to)
int sendTo (void[] buf, Address to)
int sendTo (void[] buf, Flags flags=Flags.NONE)
int receive (void[] buf, Flags flags=Flags.NONE)
int receiveFrom (void[] buf, Flags flags, out Address from)
int receiveFrom (void[] buf, out Address from)
int receiveFrom (void[] buf, Flags flags)
int receiveFrom (void[] buf)
int getOption (OptionLevel level, Option option, void[] result)
void setOption (OptionLevel level, Option option, void[] value)
bit poll (events)
uint read (void[] dst)

Static Private Member Functions

static synchronized SocketConduit allocate (socket_t sock)
static synchronized void deallocate (SocketConduit s)
static char[] hostName ()
static uint hostAddress ()
static int select (SocketSet checkRead, SocketSet checkWrite, SocketSet checkError, timeval *tv)
static int select (SocketSet checkRead, SocketSet checkWrite, SocketSet checkError, int microseconds)
static int select (SocketSet checkRead, SocketSet checkWrite, SocketSet checkError)

Private Attributes

bool textual
SocketConduit next
bool fromList

Static Private Attributes

static SocketConduit freelist

Detailed Description

A wrapper around the bare Socket to implement the IConduit abstraction and add socket-specific functionality. SocketConduit data-transfer is typically performed in conjunction with an IBuffer instance, but can be handled directly using raw arrays if preferred. See FileConduit for examples of both approaches.

Definition at line 56 of file SocketConduit.d.


Member Typedef Documentation

typedef Socket read read
 

Definition at line 59 of file SocketConduit.d.


Member Function Documentation

deprecated this  )  [inline]
 

Create a streaming Internet Socket. Use the next ctor instead.

Definition at line 74 of file SocketConduit.d.

this bool  textual  )  [inline]
 

Create a streaming Internet Socket

Definition at line 85 of file SocketConduit.d.

References textual.

void close  )  [inline]
 

Override closure() to deallocate this SocketConduit when it has been closed. Note that one should *not* delete a SocketConduit when FreeList is enabled ...

Reimplemented from Socket.

Definition at line 99 of file SocketConduit.d.

References deallocate(), and fromList.

Referenced by HttpClient::close(), and HttpClient::open().

uint read IBuffer  target  )  [inline]
 

Read from conduit into a target buffer. Note that this uses SocketSet to handle timeouts, such that the socket does not stall forever.

(for the ISocketReader interface)

Reimplemented from ISocketReader.

Definition at line 125 of file SocketConduit.d.

References IBuffer::fill().

bool isTextual  )  [inline]
 

Returns true if this conduit is text-based

Reimplemented from Conduit.

Definition at line 136 of file SocketConduit.d.

References textual.

static SocketConduit create socket_t  handle  )  [inline, static]
 

Construct this SocketConduit with the given socket handle; this is for FreeList and ServerSocket support.

Definition at line 148 of file SocketConduit.d.

References allocate().

this socket_t  handle  )  [inline, private]
 

Construct this SocketConduit with the given socket handle; this is for FreeList and ServerSocket support.

Reimplemented from Socket.

Definition at line 161 of file SocketConduit.d.

static synchronized SocketConduit allocate socket_t  sock  )  [inline, static, private]
 

Allocate a SocketConduit from a list rather than creating a new one

Definition at line 173 of file SocketConduit.d.

References freelist, fromList, next, Socket::set(), and SocketConduit.

Referenced by create().

static synchronized void deallocate SocketConduit  s  )  [inline, static, private]
 

Return this SocketConduit to the free-list

Definition at line 197 of file SocketConduit.d.

References freelist, next, and Socket::reset().

Referenced by close().

this AddressFamily  af,
Type  type,
Protocol  protocol
[inline, protected, inherited]
 

Definition at line 931 of file Socket.d.

References Socket::create(), and type().

this ConduitStyle.Bits  style,
bool  seekable
[inline, inherited]
 

Construct a conduit with the given style and seek abilities. Conduits are either seekable or non-seekable.

Reimplemented in DeviceConduit.

Definition at line 104 of file Conduit.d.

References Conduit::filter, Conduit::seekable, and Conduit::style.

uint reader void[]  dst  )  [inline, protected, virtual, inherited]
 

conduit-specific reader

Implements Conduit.

Definition at line 811 of file Socket.d.

References SocketSet::add(), Socket::receive(), SocketSet::reset(), Socket::select(), Socket::ss, Socket::timeout, and Socket::tv.

uint writer void[]  src  )  [inline, protected, virtual, inherited]
 

Callback routine to write the provided content to the socket. This will stall until the socket responds in some manner. Returns the number of bytes sent to the output, or IConduit.Eof if the socket cannot write.

Implements Conduit.

Definition at line 855 of file Socket.d.

References Socket::send().

uint bufferSize  )  [inline, inherited]
 

Return a preferred size for buffering conduit I/O

Reimplemented from Conduit.

Definition at line 869 of file Socket.d.

void setTimeout uint  us  )  [inline, inherited]
 

Set the read timeout to the specified microseconds. Set a value of zero to disable timeout support.

Definition at line 881 of file Socket.d.

References Socket::tv.

Referenced by HttpClient::open().

bool hadTimeout  )  [inline, inherited]
 

Did the last operation result in a timeout? Note that this assumes there is no thread contention on this object.

Definition at line 894 of file Socket.d.

References Socket::timeout.

void set socket_t  sock  )  [inline, protected, inherited]
 

MANGO: moved this out from the above constructor so that it can be called from the FreeList version of SocketConduit

Definition at line 906 of file Socket.d.

Referenced by allocate(), and Socket::this().

void reset  )  [inline, protected, inherited]
 

MANGO: added to reset socket

Definition at line 917 of file Socket.d.

References INVALID_SOCKET.

Referenced by deallocate().

void create AddressFamily  af,
Type  type,
Protocol  protocol
[inline, protected, inherited]
 

MANGO: added for multicast support

Definition at line 945 of file Socket.d.

References Socket::_family, Socket::sock, and type().

Referenced by ServerSocket::createSocket(), MulticastSocket::leave(), and Socket::this().

socket_t handle  )  [inline, protected, inherited]
 

get underlying socket handle

Definition at line 960 of file Socket.d.

References Socket::sock.

Referenced by Socket::blocking(), and Socket::setGroup().

char [] toString  )  [inline, inherited]
 

Definition at line 971 of file Socket.d.

bit blocking  )  [inline, protected, inherited]
 

getter

Definition at line 983 of file Socket.d.

References Socket::handle(), and version.

Referenced by Socket::connect().

void blocking bit  byes  )  [inline, protected, inherited]
 

setter

Definition at line 1002 of file Socket.d.

References Socket::handle(), Socket::sock, SOCKET_ERROR, and version.

AddressFamily addressFamily  )  [inline, protected, inherited]
 

Definition at line 1033 of file Socket.d.

References Socket::_family.

bit isAlive  )  [inline, protected, inherited]
 

Definition at line 1044 of file Socket.d.

References Socket::sock, SOCKET_ERROR, and type().

void bind Address  addr  )  [inline, protected, inherited]
 

Definition at line 1056 of file Socket.d.

References Address::name(), Address::nameLen(), Socket::sock, and SOCKET_ERROR.

Referenced by MulticastSocket::join(), and ServerSocket::this().

void connect Address  to  )  [inline, inherited]
 

Definition at line 1068 of file Socket.d.

References assert(), Socket::blocking(), Address::name(), Address::nameLen(), Socket::sock, SOCKET_ERROR, and version.

Referenced by HttpClient::open(), and SocketAppender::setAddress().

void listen int  backlog  )  [inline, protected, inherited]
 

need to bind() first

Definition at line 1100 of file Socket.d.

References Socket::sock, and SOCKET_ERROR.

Referenced by ServerSocket::this().

Socket createSocket socket_t  handle  )  [inline, protected, inherited]
 

MANGO: added

Reimplemented in ServerSocket.

Definition at line 1112 of file Socket.d.

References Socket.

Referenced by Socket::accept().

Socket accept  )  [inline, protected, inherited]
 

Reimplemented in ServerSocket.

Definition at line 1122 of file Socket.d.

References Socket::_family, Socket::createSocket(), INVALID_SOCKET, Socket::sock, and version.

Referenced by ServerSocket::accept().

void shutdown  )  [inline, protected, inherited]
 

Definition at line 1148 of file Socket.d.

References Socket::sock.

Referenced by HttpClient::close(), and Socket::shutdown().

void shutdown Shutdown  how  )  [inline, protected, inherited]
 

Definition at line 1158 of file Socket.d.

References Socket::shutdown(), and Socket::sock.

void setLingerPeriod int  period  )  [inline, inherited]
 

MANGO: added

Reimplemented in ServerSocket.

Definition at line 1170 of file Socket.d.

References Socket::setOption().

Referenced by ServerSocket::createSocket().

void setAddressReuse bool  enabled  )  [inline, protected, inherited]
 

MANGO: added

Definition at line 1188 of file Socket.d.

References Socket::setOption().

Referenced by MulticastSocket::join(), and ServerSocket::this().

bool setGroup InternetAddress  address,
Option  option
[inline, protected, inherited]
 

Helper function to handle the adding and dropping of group membership.

MANGO: Added

Definition at line 1204 of file Socket.d.

References Socket::handle(), InternetAddress::sin, and SOCKET_ERROR.

static char [] hostName  )  [inline, static, protected, inherited]
 

Mango: added this to return the hostname

Definition at line 1294 of file Socket.d.

References SOCKET_ERROR, and strlen().

Referenced by Socket::hostAddress().

static uint hostAddress  )  [inline, static, protected, inherited]
 

Mango: added this to return the default host address (IPv4)

Definition at line 1310 of file Socket.d.

References InternetHost::addrList, assert(), InternetHost::getHostByName(), and Socket::hostName().

Address remoteAddress  )  [inline, inherited]
 

Definition at line 1326 of file Socket.d.

References Socket::_family, Address::addressFamily(), assert(), Address::name(), Address::nameLen(), Socket::newFamilyObject(), Socket::sock, and SOCKET_ERROR.

Referenced by AbstractServer::getRemoteAddress().

Address localAddress  )  [inline, inherited]
 

Definition at line 1342 of file Socket.d.

References Socket::_family, Address::addressFamily(), assert(), Address::name(), Address::nameLen(), Socket::newFamilyObject(), Socket::sock, and SOCKET_ERROR.

Referenced by AbstractServer::getHost(), and AbstractServer::getPort().

int send void[]  buf,
Flags  flags = Flags.NONE
[inline, protected, inherited]
 

returns number of bytes actually sent, or -1 on error

Definition at line 1359 of file Socket.d.

References Socket::sock.

Referenced by Socket::writer().

int sendTo void[]  buf,
Flags  flags,
Address  to
[inline, protected, inherited]
 

-to- is ignored if connected ?

Definition at line 1372 of file Socket.d.

References Address::name(), Address::nameLen(), and Socket::sock.

Referenced by Socket::sendTo().

int sendTo void[]  buf,
Address  to
[inline, protected, inherited]
 

-to- is ignored if connected ?

Definition at line 1385 of file Socket.d.

References Socket::sendTo().

int sendTo void[]  buf,
Flags  flags = Flags.NONE
[inline, protected, inherited]
 

assumes you connect()ed

Definition at line 1397 of file Socket.d.

References Socket::sock.

int receive void[]  buf,
Flags  flags = Flags.NONE
[inline, protected, inherited]
 

returns number of bytes actually received, 0 on connection closure, or -1 on error

Definition at line 1411 of file Socket.d.

References Socket::sock, and SOCKET_ERROR.

Referenced by Socket::reader().

int receiveFrom void[]  buf,
Flags  flags,
out Address  from
[inline, protected, inherited]
 

-from- is ignored if connected ?

Definition at line 1429 of file Socket.d.

References Socket::_family, assert(), from(), Address::nameLen(), Socket::newFamilyObject(), printf(), Socket::sock, SOCKET_ERROR, and version.

Referenced by Socket::receiveFrom().

int receiveFrom void[]  buf,
out Address  from
[inline, protected, inherited]
 

-from- is ignored if connected ?

Definition at line 1459 of file Socket.d.

References from(), and Socket::receiveFrom().

int receiveFrom void[]  buf,
Flags  flags
[inline, protected, inherited]
 

assumes you connect()ed

Definition at line 1471 of file Socket.d.

References Socket::sock, and SOCKET_ERROR.

int receiveFrom void[]  buf  )  [inline, protected, inherited]
 

assumes you connect()ed

Definition at line 1489 of file Socket.d.

References Socket::receiveFrom().

int getOption OptionLevel  level,
Option  option,
void[]  result
[inline, protected, inherited]
 

returns the length, in bytes, of the actual result - very different from getsockopt()

Definition at line 1502 of file Socket.d.

References Socket::sock, and SOCKET_ERROR.

void setOption OptionLevel  level,
Option  option,
void[]  value
[inline, protected, inherited]
 

Definition at line 1516 of file Socket.d.

References Socket::sock, and SOCKET_ERROR.

Referenced by Socket::setAddressReuse(), Socket::setLingerPeriod(), and MulticastSocket::setLoopback().

static int select SocketSet  checkRead,
SocketSet  checkWrite,
SocketSet  checkError,
timeval *  tv
[inline, static, protected, inherited]
 

SocketSet's are updated to include only those sockets which an event occured.

Returns the number of events, 0 on timeout, or -1 on interruption

for a connect()ing socket, writeability means connected for a listen()ing socket, readability means listening

Winsock: possibly internally limited to 64 sockets per set

Definition at line 1550 of file Socket.d.

References assert().

Referenced by Socket::poll(), and Socket::reader().

static int select SocketSet  checkRead,
SocketSet  checkWrite,
SocketSet  checkError,
int  microseconds
[inline, static, protected, inherited]
 

Definition at line 1603 of file Socket.d.

static int select SocketSet  checkRead,
SocketSet  checkWrite,
SocketSet  checkError
[inline, static, protected, inherited]
 

maximum timeout

Definition at line 1618 of file Socket.d.

bit poll events   )  [inline, inherited]
 

Definition at line 1630 of file Socket.d.

References Socket::select().

uint read void[]  dst  )  [inline, inherited]
 

read from conduit into a target buffer

Reimplemented from IConduit.

Definition at line 177 of file Conduit.d.

References Conduit::filter, and IConduitFilter::reader().

Referenced by DeviceConduit::VersionPosix::reader().


Member Data Documentation

bool textual [private]
 

Definition at line 61 of file SocketConduit.d.

Referenced by isTextual(), and this().

SocketConduit next [private]
 

Definition at line 64 of file SocketConduit.d.

Referenced by allocate(), and deallocate().

bool fromList [private]
 

Definition at line 65 of file SocketConduit.d.

Referenced by allocate(), and close().

SocketConduit freelist [static, private]
 

Definition at line 66 of file SocketConduit.d.

Referenced by allocate(), and deallocate().


The documentation for this class was generated from the following file:
Generated on Sat Dec 24 17:28:42 2005 for Mango by  doxygen 1.4.0