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

SocketConduit Class Reference

Inheritance diagram for SocketConduit:

Socket IConduit ISocketReader List of all members.

Public Member Functions

 this ()
IBuffer createBuffer ()
void setTimeout (uint us)
void attach (IConduitSource input)
void attach (IConduitSink output)
int read (IBuffer target)
int write (IBuffer source)
bool isSeekable ()
bool isReadable ()
bool isWritable ()
IConduit copy (IConduit source)
IConduit flush (IBuffer source)
ConduitStyle getStyle ()

Static Public Member Functions

SocketConduit create (socket_t handle)

Protected Member Functions

void bind (IConduitSink sink)
void bind (IConduitSource source)
void unbind ()
int reader (void[] src)
int writer (void[] src)

Private Types

enum  { Eof = -1 }

Private Member Functions

void fixup ()
 this (socket_t handle)
 this (Socket.AddressFamily af, Socket.Type type, Socket.Protocol protocol)
void set (socket_t sock)
void reset ()
void create (Socket.AddressFamily af, Socket.Type type, Socket.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 (Socket.Shutdown how)
void setLingerPeriod (int period)
void setAddressReuse (bool enabled)
bool setGroup (InternetAddress address, Socket.Option option)
void closure ()
bit poll (events)
Object getLock ()
void setLock (Object lock)
void acquire ()
bool acquireIfOpen ()
void close ()

Static Private Member Functions

bool isCancelled ()
void cancelAll (bool cancel)
int select (SocketSet checkRead, SocketSet checkWrite, SocketSet checkError, timeval *tv)
int select (SocketSet checkRead, SocketSet checkWrite, SocketSet checkError, int microseconds)
int select (SocketSet checkRead, SocketSet checkWrite, SocketSet checkError)

Private Attributes

timeval tv
SocketSet ss
IConduitSource input
IConduitSink output

Detailed Description

A wrapper around the bare Socket to implement the IConduit abstraction and add further functionality.

Definition at line 55 of file SocketConduit.d.


Member Enumeration Documentation

anonymous enum [inherited]
 

Declare the End Of File identifer

Enumeration values:
Eof 

Definition at line 64 of file IConduit.d.


Member Function Documentation

void fixup  )  [inline, private]
 

Definition at line 162 of file SocketConduit.d.

Referenced by SocketConduit::VersionUseFreeList::closure(), and this().

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 175 of file SocketConduit.d.

References SocketConduit, and version.

this  )  [inline]
 

Create a streaming Internet Socket

Reimplemented from Resource.

Definition at line 195 of file SocketConduit.d.

References fixup().

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 208 of file SocketConduit.d.

References fixup().

IBuffer createBuffer  )  [inline]
 

Create a Buffer of a conduit-specific size. I think 8K bytes is the common standard for socket buffering?

Reimplemented from IConduit.

Definition at line 221 of file SocketConduit.d.

References Buffer, and Buffer::setConduit().

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

void setTimeout uint  us  )  [inline]
 

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

Definition at line 235 of file SocketConduit.d.

References tv.

Referenced by HttpClient::open(), ConnectionPool::PoolConnection::reset(), testHttpClient(), testHttpClient2(), testSocket(), and testSocketRegex().

void attach IConduitSource  input  )  [inline]
 

Please refer to IConduit.attach for details

Reimplemented from IConduit.

Definition at line 247 of file SocketConduit.d.

References IConduitSource::bind().

void attach IConduitSink  output  )  [inline]
 

Please refer to IConduit.attach for details

Reimplemented from IConduit.

Definition at line 259 of file SocketConduit.d.

References IConduitSink::bind().

void bind IConduitSink  sink  )  [inline, protected]
 

Reimplemented from IConduitSink.

Definition at line 269 of file SocketConduit.d.

void bind IConduitSource  source  )  [inline, protected]
 

Reimplemented from IConduitSource.

Definition at line 277 of file SocketConduit.d.

void unbind  )  [inline, protected]
 

Reimplemented from IConduitSource.

Definition at line 285 of file SocketConduit.d.

int reader void[]  src  )  [inline, protected]
 

Callback routine to 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

Reimplemented from IConduitSource.

Definition at line 300 of file SocketConduit.d.

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

int writer void[]  src  )  [inline, protected]
 

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.

Reimplemented from IConduitSink.

Definition at line 336 of file SocketConduit.d.

References Socket::send().

int 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.

Reimplemented from IConduit.

Definition at line 352 of file SocketConduit.d.

Referenced by HttpClient::read(), testClient(), and testHttpClient2().

int write IBuffer  source  )  [inline]
 

Write to conduit from a source buffer.

Reimplemented from IConduit.

Definition at line 365 of file SocketConduit.d.

Referenced by flush(), and testClient().

bool isSeekable  )  [inline]
 

This conduit is not seekable

Reimplemented from IConduit.

Definition at line 383 of file SocketConduit.d.

bool isReadable  )  [inline]
 

This conduit is readable

Reimplemented from IConduit.

Definition at line 394 of file SocketConduit.d.

bool isWritable  )  [inline]
 

This conduit is writable

Reimplemented from IConduit.

Definition at line 405 of file SocketConduit.d.

IConduit copy IConduit  source  )  [inline]
 

Transfer the content of this conduit to another one. Returns true if all content was successfully copied.

Reimplemented from IConduit.

Definition at line 417 of file SocketConduit.d.

IConduit flush IBuffer  source  )  [inline]
 

Flush buffer content out to this conduit.

Returns true if all content is flushed; false if writing results in an Eof condition.

Reimplemented from IConduit.

Definition at line 440 of file SocketConduit.d.

References IBuffer::readable(), and write().

ConduitStyle getStyle  )  [inline]
 

Return the style used to open the conduit

Definition at line 454 of file SocketConduit.d.

References ConduitStyle::ReadWrite.

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

Definition at line 774 of file Socket.d.

References Resource::acquire(), and Socket::create().

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 493 of file Socket.d.

References Resource::acquire().

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

void reset  )  [inline, protected, inherited]
 

MANGO: added to reset socket

Definition at line 507 of file Socket.d.

References INVALID_SOCKET.

Referenced by SocketConduit::VersionUseFreeList::deallocate().

bool isCancelled  )  [inline, static, inherited]
 

MANGO: added for subscriber control

Definition at line 521 of file Socket.d.

References Socket::cancelled.

void cancelAll bool  cancel  )  [inline, static, inherited]
 

MANGO: added for subscriber control

Definition at line 532 of file Socket.d.

References Socket::cancelled, and version.

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

MANGO: added for multicast support

Definition at line 789 of file Socket.d.

References Socket::_family, and Socket::sock.

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

socket_t handle  )  [inline, inherited]
 

get underlying socket handle

Definition at line 804 of file Socket.d.

References Socket::sock.

Referenced by Socket::setGroup().

char [] toString  )  [inline, inherited]
 

Definition at line 815 of file Socket.d.

bit blocking  )  [inline, inherited]
 

getter

Definition at line 827 of file Socket.d.

References Socket::_blocking, and version.

void blocking bit  byes  )  [inline, inherited]
 

setter

Definition at line 846 of file Socket.d.

References Socket::_blocking, Socket::sock, SOCKET_ERROR, and version.

AddressFamily addressFamily  )  [inline, inherited]
 

Definition at line 877 of file Socket.d.

References Socket::_family.

bit isAlive  )  [inline, inherited]
 

Definition at line 888 of file Socket.d.

References Socket::sock, and SOCKET_ERROR.

void bind Address  addr  )  [inline, inherited]
 

Definition at line 900 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 912 of file Socket.d.

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

Referenced by HttpClient::open(), ConnectionPool::PoolConnection::reset(), VersionMango::SocketAppender::setAddress(), testClient(), testClusterServer(), testHttpClient(), testHttpClient2(), testSocket(), and testSocketRegex().

void listen int  backlog  )  [inline, inherited]
 

need to bind() first

Definition at line 944 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 956 of file Socket.d.

References Socket.

Referenced by Socket::accept().

Socket accept  )  [inline, inherited]
 

Reimplemented in ServerSocket.

Definition at line 966 of file Socket.d.

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

Referenced by ServerSocket::accept().

void shutdown  )  [inline, inherited]
 

Definition at line 992 of file Socket.d.

References Socket::sock.

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

void shutdown Socket.Shutdown  how  )  [inline, inherited]
 

Definition at line 1002 of file Socket.d.

References Socket::sock.

void setLingerPeriod int  period  )  [inline, inherited]
 

MANGO: added

Reimplemented in ServerSocket.

Definition at line 1014 of file Socket.d.

References Socket::setOption().

Referenced by ServerSocket::createSocket(), and testClient().

void setAddressReuse bool  enabled  )  [inline, inherited]
 

MANGO: added

Definition at line 1032 of file Socket.d.

References Socket::setOption().

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

bool setGroup InternetAddress  address,
Socket.Option  option
[inline, inherited]
 

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

MANGO: Added

Definition at line 1048 of file Socket.d.

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

Referenced by MulticastSocket::pauseGroup(), and MulticastSocket::resumeGroup().

void closure  )  [inline, inherited]
 

calling shutdown() before this is recommended for connection- oriented sockets

MANGO: changed from close() to IResource.closure()

Reimplemented from Resource.

Definition at line 1073 of file Socket.d.

References Socket::sock, and version.

Referenced by MulticastSocket::leave().

int select SocketSet  checkRead,
SocketSet  checkWrite,
SocketSet  checkError,
timeval *  tv
[inline, static, 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 1378 of file Socket.d.

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

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

Definition at line 1431 of file Socket.d.

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

maximum timeout

Definition at line 1446 of file Socket.d.

bit poll events   )  [inline, inherited]
 

Definition at line 1458 of file Socket.d.

References Socket::select().

Object getLock  )  [inherited]
 

Return the lock used by this resource

Reimplemented in Resource.

void setLock Object  lock  )  [inherited]
 

Set an alternate lock. Typically one would use this to synchronize multiple different Resources via a common object.

Reimplemented in Resource.

void acquire  )  [inherited]
 

hold a reference to this resource. The caller is now responsible for invoking close() upon this resource;

Reimplemented in Resource.

bool acquireIfOpen  )  [inherited]
 

If this resource is still open, acquire it and return true. This is a threadsafe test-and-set mechanism that fails only if the resource is already closed, or was never opened.

Note that you are responsible for invoking close() whenever this method returns true.

Reimplemented in Resource.

void close  )  [inherited]
 

release a reference to this resource

Reimplemented in Resource.

Referenced by HttpClient::close(), ConnectionPool::PoolConnection::close(), HttpBridge::cross(), ClusterThread::run(), and testClient().


Member Data Documentation

timeval tv [private]
 

Definition at line 57 of file SocketConduit.d.

Referenced by reader(), and setTimeout().

SocketSet ss [private]
 

Definition at line 58 of file SocketConduit.d.

Referenced by reader().

IConduitSource input [private]
 

Definition at line 59 of file SocketConduit.d.

IConduitSink output [private]
 

Definition at line 60 of file SocketConduit.d.


The documentation for this class was generated from the following file:
Generated on Sun Nov 7 19:07:11 2004 for Mango by doxygen 1.3.6