SOCK_Dgram_Bcast.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    SOCK_Dgram_Bcast.h
00006  *
00007  *  SOCK_Dgram_Bcast.h,v 4.26 2005/11/26 03:13:13 ossama Exp
00008  *
00009  *  @author Doug Schmidt
00010  */
00011 //=============================================================================
00012 
00013 
00014 #ifndef ACE_SOCK_DGRAM_BCAST_H
00015 #define ACE_SOCK_DGRAM_BCAST_H
00016 #include /**/ "ace/pre.h"
00017 
00018 #include "ace/ACE_export.h"
00019 
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 # pragma once
00022 #endif /* ACE_LACKS_PRAGMA_ONCE */
00023 
00024 #include "ace/SOCK_Dgram.h"
00025 #include "ace/INET_Addr.h"
00026 
00027 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00028 
00029 /**
00030  * @class ACE_Bcast_Node
00031  *
00032  * @brief Linked list of broadcast interfaces.
00033  */
00034 class ACE_Export ACE_Bcast_Node
00035 {
00036 public:
00037   /// Default constructor.
00038   ACE_Bcast_Node (ACE_INET_Addr &,
00039                   ACE_Bcast_Node *);
00040 
00041   /// Destructor.
00042   ~ACE_Bcast_Node (void);
00043 
00044   /// Broadcast address for the interface.
00045   ACE_INET_Addr bcast_addr_;
00046 
00047   /// Pointer to the next interface in the chain.
00048   ACE_Bcast_Node *next_;
00049 };
00050 
00051 /**
00052  * @class ACE_SOCK_Dgram_Bcast
00053  *
00054  * @brief Defines the member functions for the ACE_SOCK datagram
00055  * abstraction.
00056  */
00057 class ACE_Export ACE_SOCK_Dgram_Bcast : public ACE_SOCK_Dgram
00058 {
00059 public:
00060   // = Initialization and termination methods.
00061   /// Default constructor.
00062   ACE_SOCK_Dgram_Bcast (void);
00063 
00064   ACE_SOCK_Dgram_Bcast (const ACE_Addr &local,
00065                         int protocol_family = PF_INET,
00066                         int protocol = 0,
00067                         int reuse_addr = 0,
00068                         const ACE_TCHAR *host_name = 0);
00069 
00070   /// Default dtor.
00071   ~ACE_SOCK_Dgram_Bcast (void);
00072 
00073   // Initiate a connectionless datagram broadcast endpoint.
00074 
00075   /// Initiate a connectionless datagram broadcast endpoint.
00076   int open (const ACE_Addr &local,
00077             int protocol_family = PF_INET,
00078             int protocol = 0,
00079             int reuse_addr = 0,
00080             const ACE_TCHAR *host_name = 0);
00081 
00082   /// Close up and release dynamically allocated resources.
00083   int close (void);
00084 
00085   /// Broadcast the datagram to every interface.  Returns the average
00086   /// number of bytes sent.
00087   ssize_t send (const void *buf,
00088                 size_t n,
00089                 u_short portnum,
00090                 int flags = 0) const;
00091 
00092   /// Broadcast the <iovec> datagrams to every interface.  Returns the
00093   /// average number of bytes sent.
00094   ssize_t send (const iovec iov[],
00095                 int n,
00096                 u_short portnum,
00097                 int flags = 0) const;
00098 
00099   /// Broadcast an N byte datagram to ADDR (note that addr must be
00100   /// preassigned to the broadcast address of the subnet...).
00101   ssize_t send (const void *buf,
00102                 size_t n,
00103                 const ACE_Addr &addr,
00104                 int flags = 0) const;
00105 
00106   /**
00107    * Broadcast an @a iovec of size @a n to @a addr as a datagram (note
00108    * that addr must be preassigned to the broadcast address of the
00109    * subnet...)
00110    */
00111   ssize_t send (const iovec iov[],
00112                 int n,
00113                 const ACE_Addr &addr,
00114                 int flags = 0) const;
00115 
00116   /// Dump the state of an object.
00117   void dump (void) const;
00118 
00119   /// Declare the dynamic allocation hooks.
00120   ACE_ALLOC_HOOK_DECLARE;
00121 
00122 private:
00123   /// Make broadcast available for Datagram socket.
00124   int mk_broadcast (const ACE_TCHAR *host_name);
00125 
00126   /// Points to the head of the list of broadcast interfaces.
00127   ACE_Bcast_Node *if_list_;
00128 
00129   /// Do not allow this function to percolate up to this interface...
00130   int get_remote_addr (ACE_Addr &) const;
00131 };
00132 
00133 ACE_END_VERSIONED_NAMESPACE_DECL
00134 
00135 #if defined (__ACE_INLINE__)
00136 #include "ace/SOCK_Dgram_Bcast.inl"
00137 #endif /* __ACE_INLINE__ */
00138 
00139 #include /**/ "ace/post.h"
00140 #endif /* ACE_SOCK_DGRAM_BCAST_H */

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