SOCK.h

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    SOCK.h
00006  *
00007  *  SOCK.h,v 4.40 2005/10/28 16:14:55 ossama Exp
00008  *
00009  *  @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
00010  */
00011 //=============================================================================
00012 
00013 #ifndef ACE_SOCK_H
00014 #define ACE_SOCK_H
00015 #include /**/ "ace/pre.h"
00016 
00017 #include "ace/ACE_export.h"
00018 
00019 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00020 # pragma once
00021 #endif /* ACE_LACKS_PRAGMA_ONCE */
00022 
00023 #include "ace/Addr.h"
00024 #include "ace/IPC_SAP.h"
00025 #include "ace/OS_NS_stropts.h"
00026 
00027 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00028 
00029 /**
00030  * @class ACE_SOCK
00031  *
00032  * @brief An abstract class that forms the basis for more specific
00033  * classes, such as <ACE_SOCK_Acceptor> and <ACE_SOCK_Stream>.
00034  * Do not instantiate this class.
00035  *
00036  * This class provides functions that are common to all of the
00037  * <ACE_SOCK_*> classes. <ACE_SOCK> provides the ability to get
00038  * and set socket options, get the local and remote addresses,
00039  * and open and close a socket handle.
00040  */
00041 class ACE_Export ACE_SOCK : public ACE_IPC_SAP
00042 {
00043 public:
00044 
00045   /// Wrapper around the <setsockopt> system call.
00046   int set_option (int level,
00047                   int option,
00048                   void *optval,
00049                   int optlen) const;
00050 
00051   /// Wrapper around the <getsockopt> system call.
00052   int get_option (int level,
00053                   int option,
00054                   void *optval,
00055                   int *optlen) const;
00056 
00057   /**
00058    * Close the socket.
00059    * This method also sets the object's handle value to ACE_INVALID_HANDLE.
00060    *
00061    * @return The result of closing the socket; 0 if the handle value
00062    *         was already ACE_INVALID_HANDLE.
00063    */
00064   int close (void);
00065 
00066   /// Return the local endpoint address in the referenced <ACE_Addr>.
00067   /// Returns 0 if successful, else -1.
00068   int get_local_addr (ACE_Addr &) const;
00069 
00070   /**
00071    * Return the address of the remotely connected peer (if there is
00072    * one), in the referenced <ACE_Addr>. Returns 0 if successful, else
00073    * -1.
00074    */
00075   int get_remote_addr (ACE_Addr &) const;
00076 
00077   /// Dump the state of an object.
00078   void dump (void) const;
00079 
00080   /// Declare the dynamic allocation hooks.
00081   ACE_ALLOC_HOOK_DECLARE;
00082 
00083   /// Wrapper around the BSD-style <socket> system call (no QoS).
00084   int open (int type,
00085             int protocol_family,
00086             int protocol,
00087             int reuse_addr);
00088 
00089   /// Wrapper around the QoS-enabled <WSASocket> function.
00090   int open (int type,
00091             int protocol_family,
00092             int protocol,
00093             ACE_Protocol_Info *protocolinfo,
00094             ACE_SOCK_GROUP g,
00095             u_long flags,
00096             int reuse_addr);
00097 
00098 protected:
00099 
00100   /// Constructor with arguments to call the BSD-style <socket> system
00101   /// call (no QoS).
00102   ACE_SOCK (int type,
00103             int protocol_family,
00104             int protocol = 0,
00105             int reuse_addr = 0);
00106 
00107   /// Constructor with arguments to call the QoS-enabled <WSASocket>
00108   /// function.
00109   ACE_SOCK (int type,
00110             int protocol_family,
00111             int protocol,
00112             ACE_Protocol_Info *protocolinfo,
00113             ACE_SOCK_GROUP g,
00114             u_long flags,
00115             int reuse_addr);
00116 
00117   /// Default constructor is protected to prevent instances of this class
00118   /// from being defined.
00119   ACE_SOCK (void);
00120 
00121   /// Protected destructor.
00122   /**
00123    * Not a virtual destructor.  Protected destructor to prevent
00124    * operator delete() from being called through a base class ACE_SOCK
00125    * pointer/reference.
00126    */
00127   ~ACE_SOCK (void);
00128 
00129 };
00130 
00131 ACE_END_VERSIONED_NAMESPACE_DECL
00132 
00133 #if defined (__ACE_INLINE__)
00134 #include "ace/SOCK.inl"
00135 #endif /* __ACE_INLINE__ */
00136 
00137 #include /**/ "ace/post.h"
00138 #endif /* ACE_SOCK_H */

Generated on Thu Nov 9 09:42:03 2006 for ACE by doxygen 1.3.6