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

SOCK_Dgram.h

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    SOCK_Dgram.h
00006  *
00007  *  $Id: SOCK_Dgram.h,v 1.1.1.4 2003/02/21 18:36:32 chad Exp $
00008  *
00009  *  @author Doug Schmidt
00010  */
00011 //=============================================================================
00012 
00013 
00014 #ifndef ACE_SOCK_DGRAM_H
00015 #define ACE_SOCK_DGRAM_H
00016 #include "ace/pre.h"
00017 
00018 #include "ace/SOCK.h"
00019 #include "ace/INET_Addr.h"
00020 
00021 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00022 # pragma once
00023 #endif /* ACE_LACKS_PRAGMA_ONCE */
00024 
00025 #include "ace/Addr.h"
00026 
00027 /**
00028  * @class ACE_SOCK_Dgram
00029  *
00030  * @brief Defines the member functions for the ACE_SOCK datagram
00031  * abstraction.
00032  */
00033 class ACE_Export ACE_SOCK_Dgram : public ACE_SOCK
00034 {
00035 public:
00036   // = Initialization and termination methods.
00037   /// Default constructor.
00038   ACE_SOCK_Dgram (void);
00039 
00040   /// This is a BSD-style method (i.e., no QoS) for initiating a socket
00041   /// dgram that will accept datagrams at the <local> address.
00042   ACE_SOCK_Dgram (const ACE_Addr &local,
00043                   int protocol_family = ACE_PROTOCOL_FAMILY_INET,
00044                   int protocol = 0,
00045                   int reuse_addr = 0);
00046 
00047   /**
00048    * This is a QoS-enabed method for initiating a socket dgram that
00049    * will accept datagrams at the <local> address.  The <qos_params>
00050    * are passed to <ACE_OS::join_leaf>.
00051    */
00052   ACE_SOCK_Dgram (const ACE_Addr &local,
00053                   int protocol_family,
00054                   int protocol,
00055                   ACE_Protocol_Info *protocolinfo,
00056                   ACE_SOCK_GROUP g = 0,
00057                   u_long flags = 0,
00058                   int reuse_addr = 0);
00059 
00060   /// This is a BSD-style method (i.e., no QoS) for initiating a socket
00061   /// dgram that will accept datagrams at the <local> address.
00062   int open (const ACE_Addr &local,
00063             int protocol_family = ACE_PROTOCOL_FAMILY_INET,
00064             int protocol = 0,
00065             int reuse_addr = 0);
00066 
00067   /**
00068    * This is a QoS-enabed method for initiating a socket dgram that
00069    * will accept datagrams at the <local> address.  The <qos_params>
00070    * are passed to <ACE_OS::join_leaf>.
00071    */
00072   int open (const ACE_Addr &local,
00073             int protocol_family,
00074             int protocol,
00075             ACE_Protocol_Info *protocolinfo,
00076             ACE_SOCK_GROUP g = 0,
00077             u_long flags = 0,
00078             int reuse_addr = 0);
00079 
00080   /// Default dtor.
00081   ~ACE_SOCK_Dgram (void);
00082 
00083   // = Data transfer routines.
00084   /// Send an <n> byte <buf> to the datagram socket (uses <sendto(3)>).
00085   ssize_t send (const void *buf,
00086                 size_t n,
00087                 const ACE_Addr &addr,
00088                 int flags = 0) const;
00089 
00090   /// Receive an <n> byte <buf> from the datagram socket (uses
00091   /// <recvfrom(3)>).
00092   ssize_t recv (void *buf,
00093                 size_t n,
00094                 ACE_Addr &addr,
00095                 int flags = 0) const;
00096 
00097   /**
00098    * Allows a client to read from a socket without having to provide a
00099    * buffer to read.  This method determines how much data is in the
00100    * socket, allocates a buffer of this size, reads in the data, and
00101    * returns the number of bytes read.  The caller is responsible for
00102    * deleting the member in the <iov_base> field of <io_vec> using the
00103    * ``delete []'' syntax.
00104    */
00105   ssize_t recv (iovec *io_vec,
00106                 ACE_Addr &addr,
00107                 int flags = 0,
00108                 const ACE_Time_Value *timeout = 0) const;
00109 
00110   /// Send an <iovec> of size <n> to the datagram socket (uses
00111   /// <sendmsg(3)>).
00112   ssize_t send (const iovec iov[],
00113                 int n,
00114                 const ACE_Addr &addr,
00115                 int flags = 0) const;
00116 
00117   /// Recv an <iovec> of size <n> to the datagram socket (uses
00118   /// <recvmsg(3)>).
00119   ssize_t recv (iovec iov[],
00120                 int n,
00121                 ACE_Addr &addr,
00122                 int flags = 0) const;
00123 
00124   /**
00125    * Wait up to <timeout> amount of time to receive a datagram into
00126    * <buf>.  The <ACE_Time_Value> indicates how long to blocking
00127    * trying to receive.  If <timeout> == 0, the caller will block
00128    * until action is possible, else will wait until the relative time
00129    * specified in *<timeout> elapses).  If <recv> times out a -1 is
00130    * returned with <errno == ETIME>.  If it succeeds the number of
00131    * bytes received is returned.
00132    */
00133   ssize_t recv (void *buf,
00134                 size_t n,
00135                 ACE_Addr &addr,
00136                 int flags,
00137                 const ACE_Time_Value *timeout) const;
00138 
00139   /**
00140    * Wait up to <timeout> amount of time to send a datagram to
00141    * <buf>.  The <ACE_Time_Value> indicates how long to blocking
00142    * trying to receive.  If <timeout> == 0, the caller will block
00143    * until action is possible, else will wait until the relative time
00144    * specified in *<timeout> elapses).  If <send> times out a -1 is
00145    * returned with <errno == ETIME>.  If it succeeds the number of
00146    * bytes sent is returned.
00147    */
00148   ssize_t send (const void *buf,
00149                 size_t n,
00150                 const ACE_Addr &addr,
00151                 int flags,
00152                 const ACE_Time_Value *timeout) const;
00153 
00154   /// Send <buffer_count> worth of <buffers> to <addr> using overlapped
00155   /// I/O (uses <WSASendTo>).  Returns 0 on success.
00156   ssize_t send (const iovec buffers[],
00157                 int buffer_count,
00158                 size_t &number_of_bytes_sent,
00159                 int flags,
00160                 const ACE_Addr &addr,
00161                 ACE_OVERLAPPED *overlapped,
00162                 ACE_OVERLAPPED_COMPLETION_FUNC func) const;
00163 
00164   /// Recv <buffer_count> worth of <buffers> from <addr> using
00165   /// overlapped I/O (uses <WSARecvFrom>).  Returns 0 on success.
00166   ssize_t recv (iovec buffers[],
00167                 int buffer_count,
00168                 size_t &number_of_bytes_recvd,
00169                 int &flags,
00170                 ACE_Addr &addr,
00171                 ACE_OVERLAPPED *overlapped,
00172                 ACE_OVERLAPPED_COMPLETION_FUNC func) const;
00173 
00174   /// Send an <n> byte <buf> to the datagram socket (uses <WSASendTo>).
00175   ssize_t send (const void *buf,
00176                 size_t n,
00177                 const ACE_Addr &addr,
00178                 int flags,
00179                 ACE_OVERLAPPED *overlapped,
00180                 ACE_OVERLAPPED_COMPLETION_FUNC func) const;
00181 
00182   /// Receive an <n> byte <buf> from the datagram socket (uses
00183   /// <WSARecvFrom>).
00184   ssize_t recv (void *buf,
00185                 size_t n,
00186                 ACE_Addr &addr,
00187                 int flags,
00188                 ACE_OVERLAPPED *overlapped,
00189                 ACE_OVERLAPPED_COMPLETION_FUNC func) const;
00190 
00191   // = Meta-type info.
00192   typedef ACE_INET_Addr PEER_ADDR;
00193 
00194   /// Dump the state of an object.
00195   void dump (void) const;
00196 
00197   void set_nic (const char *option_value);
00198 
00199   /// Declare the dynamic allocation hooks.
00200   ACE_ALLOC_HOOK_DECLARE;
00201 
00202 protected:
00203   /// Open is shared by this and by <LSOCK_Dgram>.
00204   int shared_open (const ACE_Addr &local,
00205                    int protocol_family);
00206 
00207 private:
00208   /// Do not allow this function to percolate up to this interface...
00209   int  get_remote_addr (ACE_Addr &) const;
00210 };
00211 
00212 #if !defined (ACE_LACKS_INLINE_FUNCTIONS)
00213 #include "ace/SOCK_Dgram.i"
00214 #endif
00215 
00216 #include "ace/post.h"
00217 #endif /* ACE_SOCK_DGRAM_H */

Generated on Mon Jun 16 11:21:19 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002