Cross-Platform C++

ot::net
class SocketDescriptor

#include "ot/net/SocketDescriptor.h"

ot::io::ResourceDescriptor ot::SynchronizedObject ot::ManagedObject ot::ManagedObject An abstract base class representing socket handles. By using reference-counted SocketDescriptors, OpenTop is able to share socket handles between multiple objects, preventing the socket from being closed until all references to the SocketDescriptor have been removed.

This is a SynchronizedObject to allow OpenTop to synchronize some socket operations so that they may be safely called by multiple threads.




Constructor/Destructor Summary
SocketDescriptor(OSSocketDescriptorType fd)
         Constructs a SocketDescriptor from an operating system socket handle.
~SocketDescriptor()
         Destructor.

Method Summary
 void close()
         Closes the socket.
 OSSocketDescriptorType getFD() const
         Returns an operating system handle for the socket.
 int getSocketFlags() const
         Returns the current socket flags.
 int modifySocketFlags(int flagsToSet, int flagsToUnset)
         Sets the socket flags.
 void setSocketFlags(int flags)
         Sets the socket flags.
 virtual String toString() const
         Returns a string representation of this ResourceDescriptor.

Methods inherited from class ot::ManagedObject
addRef, getRefCount, onFinalRelease, operator=, release

Methods inherited from class ot::io::ResourceDescriptor
getAutoClose, setAutoClose

Methods inherited from class ot::SynchronizedObject
lock, unlock

Typedefs

OSSocketDescriptorType

typedef int OSSocketDescriptorType

Enumerations

enum Flags { ShutdownInput =1,   
  ShutdownOutput =2,   
  HasOutputStream =4,   
  DescriptorClosed =8,   
  AutoCloseEnabled =16}   


Constructor/Destructor Detail

SocketDescriptor

 SocketDescriptor(OSSocketDescriptorType fd)
Constructs a SocketDescriptor from an operating system socket handle.


~SocketDescriptor

 ~SocketDescriptor()
Destructor. Calls getAutoClose() and closes the related resource if it returns true.


Method Detail

close

void close()
Closes the socket.


getFD

OSSocketDescriptorType getFD() const
Returns an operating system handle for the socket.


getSocketFlags

int getSocketFlags() const
Returns the current socket flags.

See also:
setSocketFlags
Multi-threaded considerations:
Can safely be called from multiple concurrent threads.

modifySocketFlags

int modifySocketFlags(int flagsToSet,
                      int flagsToUnset)
Sets the socket flags. Each open socket has a set of flags associated with it for use by internal OpenTop routines.

Parameters:
flagsToSet - a value whose bits are ORed with the existing flag bits to arrive at a new value.
flagsToUnset - a value whose bits are NANDedd with the existing flag bits to arrive at a new value.
Returns:
the new flag value
Multi-threaded considerations:
Can safely be called from multiple concurrent threads.

setSocketFlags

void setSocketFlags(int flags)
Sets the socket flags. Each open socket has a set of flags associated with it for use by internal OpenTop routines.

Parameters:
flags - the new flag value
Multi-threaded considerations:
Can safely be called from multiple concurrent threads.

toString

virtual String toString() const
Returns a string representation of this ResourceDescriptor. OpenTop uses the string representation to identify the resource descriptor when tracing via the Tracer class.

Since:
1.3


Cross-Platform C++

Found a bug or missing feature? Please email us at support@elcel.com

Copyright © 2000-2003 ElCel Technology   Trademark Acknowledgements