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

Socket Class Reference

Inheritance diagram for Socket:

Resource DatagramSocket ServerSocket SocketConduit MulticastSocket List of all members.

Public Member Functions

 this (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 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)

Static Public 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)

Protected Member Functions

 this (socket_t sock)
void set (socket_t sock)
void reset ()
void create (Socket.AddressFamily af, Socket.Type type, Socket.Protocol protocol)
Socket createSocket (socket_t handle)

Private Member Functions

Address newFamilyObject ()
Address remoteAddress ()
Address localAddress ()
int send (void[] buf, Socket.Flags flags=Socket.Flags.NONE)
int sendTo (void[] buf, Socket.Flags flags, Address to)
int sendTo (void[] buf, Address to)
int sendTo (void[] buf, Socket.Flags flags=Socket.Flags.NONE)
int receive (void[] buf, Socket.Flags flags=Socket.Flags.NONE)
int receiveFrom (void[] buf, Socket.Flags flags, out Address from)
int receiveFrom (void[] buf, out Address from)
int receiveFrom (void[] buf, Socket.Flags flags)
int receiveFrom (void[] buf)
int getOption (Socket.OptionLevel level, Socket.Option option, void[] result)
void setOption (Socket.OptionLevel level, Socket.Option option, void[] value)
 this ()
Object getLock ()
void setLock (Object lock)
void acquire ()
bool acquireIfOpen ()
void close ()

Static Private Member Functions

char[] hostName ()
uint hostAddress ()

Private Attributes

socket_t sock
Socket AddressFamily _family
public class VersionWin32 bit _blocking = false
Object _lock

Static Private Attributes

bool cancelled

Detailed Description

MANGO: socket now subclasses mango.io.Resource

Definition at line 462 of file Socket.d.


Member Function Documentation

this socket_t  sock  )  [inline, protected]
 

Construct a Socket from a handle. This is used internally to create new Sockets via an accept().

Reimplemented in SocketConduit.

Definition at line 480 of file Socket.d.

References set(), and sock.

void set socket_t  sock  )  [inline, protected]
 

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 this().

void reset  )  [inline, protected]
 

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]
 

MANGO: added for subscriber control

Definition at line 521 of file Socket.d.

References cancelled.

void cancelAll bool  cancel  )  [inline, static]
 

MANGO: added for subscriber control

Definition at line 532 of file Socket.d.

References cancelled, and version.

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

Definition at line 774 of file Socket.d.

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

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

MANGO: added for multicast support

Definition at line 789 of file Socket.d.

References _family, and sock.

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

socket_t handle  )  [inline]
 

get underlying socket handle

Definition at line 804 of file Socket.d.

References sock.

Referenced by setGroup().

char [] toString  )  [inline]
 

Definition at line 815 of file Socket.d.

bit blocking  )  [inline]
 

getter

Definition at line 827 of file Socket.d.

References _blocking, and version.

void blocking bit  byes  )  [inline]
 

setter

Definition at line 846 of file Socket.d.

References _blocking, sock, SOCKET_ERROR, and version.

AddressFamily addressFamily  )  [inline]
 

Definition at line 877 of file Socket.d.

References _family.

bit isAlive  )  [inline]
 

Definition at line 888 of file Socket.d.

References sock, and SOCKET_ERROR.

void bind Address  addr  )  [inline]
 

Definition at line 900 of file Socket.d.

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

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

void connect Address  to  )  [inline]
 

Definition at line 912 of file Socket.d.

References Address::name(), Address::nameLen(), 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]
 

need to bind() first

Definition at line 944 of file Socket.d.

References sock, and SOCKET_ERROR.

Referenced by ServerSocket::this().

Socket createSocket socket_t  handle  )  [inline, protected]
 

MANGO: added

Reimplemented in ServerSocket.

Definition at line 956 of file Socket.d.

References Socket.

Referenced by accept().

Socket accept  )  [inline]
 

Reimplemented in ServerSocket.

Definition at line 966 of file Socket.d.

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

Referenced by ServerSocket::accept().

void shutdown  )  [inline]
 

Definition at line 992 of file Socket.d.

References sock.

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

void shutdown Socket.Shutdown  how  )  [inline]
 

Definition at line 1002 of file Socket.d.

References sock.

void setLingerPeriod int  period  )  [inline]
 

MANGO: added

Reimplemented in ServerSocket.

Definition at line 1014 of file Socket.d.

References setOption().

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

void setAddressReuse bool  enabled  )  [inline]
 

MANGO: added

Definition at line 1032 of file Socket.d.

References setOption().

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

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

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

MANGO: Added

Definition at line 1048 of file Socket.d.

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

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

void closure  )  [inline]
 

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 sock, and version.

Referenced by MulticastSocket::leave().

Address newFamilyObject  )  [inline, private]
 

Definition at line 1100 of file Socket.d.

References _family.

Referenced by localAddress(), receiveFrom(), and remoteAddress().

char [] hostName  )  [inline, static, private]
 

Mango: added this to return the hostname

Definition at line 1122 of file Socket.d.

References SOCKET_ERROR.

Referenced by hostAddress().

uint hostAddress  )  [inline, static, private]
 

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

Definition at line 1138 of file Socket.d.

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

Address remoteAddress  )  [inline, private]
 

Definition at line 1154 of file Socket.d.

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

Address localAddress  )  [inline, private]
 

Definition at line 1170 of file Socket.d.

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

int send void[]  buf,
Socket.Flags  flags = Socket.Flags.NONE
[inline, private]
 

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

Definition at line 1187 of file Socket.d.

References sock.

Referenced by SocketConduit::writer().

int sendTo void[]  buf,
Socket.Flags  flags,
Address  to
[inline, private]
 

-to- is ignored if connected ?

Definition at line 1200 of file Socket.d.

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

Referenced by sendTo().

int sendTo void[]  buf,
Address  to
[inline, private]
 

-to- is ignored if connected ?

Definition at line 1213 of file Socket.d.

References sendTo().

int sendTo void[]  buf,
Socket.Flags  flags = Socket.Flags.NONE
[inline, private]
 

assumes you connect()ed

Definition at line 1225 of file Socket.d.

References sock.

int receive void[]  buf,
Socket.Flags  flags = Socket.Flags.NONE
[inline, private]
 

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

Definition at line 1239 of file Socket.d.

References sock, and SOCKET_ERROR.

Referenced by SocketConduit::reader().

int receiveFrom void[]  buf,
Socket.Flags  flags,
out Address  from
[inline, private]
 

-from- is ignored if connected ?

Definition at line 1257 of file Socket.d.

References _family, newFamilyObject(), sock, SOCKET_ERROR, and version.

Referenced by receiveFrom().

int receiveFrom void[]  buf,
out Address  from
[inline, private]
 

-from- is ignored if connected ?

Definition at line 1287 of file Socket.d.

References receiveFrom().

int receiveFrom void[]  buf,
Socket.Flags  flags
[inline, private]
 

assumes you connect()ed

Definition at line 1299 of file Socket.d.

References sock, and SOCKET_ERROR.

int receiveFrom void[]  buf  )  [inline, private]
 

assumes you connect()ed

Definition at line 1317 of file Socket.d.

References receiveFrom().

int getOption Socket.OptionLevel  level,
Socket.Option  option,
void[]  result
[inline, private]
 

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

Definition at line 1330 of file Socket.d.

References sock, and SOCKET_ERROR.

void setOption Socket.OptionLevel  level,
Socket.Option  option,
void[]  value
[inline, private]
 

Definition at line 1344 of file Socket.d.

References sock, and SOCKET_ERROR.

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

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

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 poll(), and SocketConduit::reader().

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

Definition at line 1431 of file Socket.d.

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

maximum timeout

Definition at line 1446 of file Socket.d.

bit poll events   )  [inline]
 

Definition at line 1458 of file Socket.d.

References select().

this  )  [inline, inherited]
 

Set the default lock to be this object

Reimplemented in DatagramSocket, and SocketConduit.

Definition at line 74 of file Resource.d.

References Resource::_lock.

Object getLock  )  [inline, inherited]
 

Return the lock used by this resource

Reimplemented from IResource.

Definition at line 101 of file Resource.d.

References Resource::_lock.

void setLock Object  lock  )  [inline, inherited]
 

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

Reimplemented from IResource.

Definition at line 115 of file Resource.d.

void acquire  )  [inline, inherited]
 

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

Reimplemented from IResource.

Definition at line 130 of file Resource.d.

References Resource::_lock, and Resource::usage.

Referenced by set(), this(), and FileConduit::this().

bool acquireIfOpen  )  [inline, 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 from IResource.

Definition at line 149 of file Resource.d.

References Resource::_lock, and Resource::usage.

void close  )  [inline, inherited]
 

release a reference to this resource

Reimplemented from IResource.

Definition at line 168 of file Resource.d.

References Resource::_lock, Resource::closure(), and Resource::usage.

Referenced by Resource::~this(), and FileConduit::VersionWin32::Win32MappedBuffer::~this().


Member Data Documentation

socket_t sock [private]
 

Definition at line 465 of file Socket.d.

Referenced by accept(), bind(), blocking(), closure(), connect(), create(), getOption(), handle(), isAlive(), listen(), localAddress(), receive(), receiveFrom(), remoteAddress(), send(), sendTo(), setOption(), shutdown(), and this().

Socket AddressFamily _family [private]
 

Definition at line 466 of file Socket.d.

Referenced by accept(), addressFamily(), create(), localAddress(), newFamilyObject(), receiveFrom(), and remoteAddress().

bool cancelled [static, private]
 

Definition at line 467 of file Socket.d.

Referenced by cancelAll(), and isCancelled().

public class VersionWin32 bit _blocking = false [private]
 

Definition at line 470 of file Socket.d.

Referenced by accept(), and blocking().

Object _lock [protected, inherited]
 

Definition at line 51 of file Resource.d.

Referenced by Resource::acquire(), Resource::acquireIfOpen(), Resource::close(), Resource::getLock(), and Resource::this().


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