SOCK_SEQPACK_Association.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *
00006  *  @file    SOCK_SEQPACK_Association.h
00007  *
00008  *  SOCK_SEQPACK_Association.h,v 4.14 2006/06/08 11:28:51 jwillemsen Exp
00009  *
00010  *  @author  Patrick J. Lardieri <plardier@atl.lmco.com>
00011  *  @author  Gaurav Naik, Lockheed Martin ATL
00012  *  @author  based on SOCK_Stream
00013  *            by Douglas C. Schmidt <schmidt@cs.wustl.edu>
00014  *
00015  */
00016 //=============================================================================
00017 
00018 #ifndef ACE_SOCK_SEQPACK_ASSOCIATION_H
00019 #define ACE_SOCK_SEQPACK_ASSOCIATION_H
00020 
00021 #include /**/ "ace/pre.h"
00022 
00023 #include "ace/ACE_export.h"
00024 
00025 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00026 # pragma once
00027 #endif /* ACE_LACKS_PRAGMA_ONCE */
00028 
00029 #include "ace/SOCK_IO.h"
00030 #include "ace/Multihomed_INET_Addr.h"
00031 
00032 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00033 
00034 // Forward declarations.
00035 class ACE_Message_Block;
00036 
00037 /**
00038  * @class ACE_SOCK_SEQPACK_Association
00039  *
00040  * @brief Defines the methods in the <ACE_SOCK_SEQPACK_Association> abstraction.
00041  *
00042  * This adds additional wrapper methods atop the <ACE_SOCK_IO>
00043  * class.
00044  *
00045  * <buf> is the buffer to write from or receive into.
00046  * <len> is the number of bytes to transfer.
00047  * The <timeout> parameter in the following methods indicates how
00048  * long to blocking trying to transfer data.  If <timeout> == 0,
00049  * then the call behaves as a normal send/recv call, i.e., for
00050  * blocking sockets, the call will block until action is possible;
00051  * for non-blocking sockets, EWOULDBLOCK will be returned if no
00052  * action is immediately possible.
00053  * If <timeout> != 0, the call will wait for data to arrive no longer
00054  * than the relative time specified in *<timeout>.
00055  * The "_n()" I/O methods keep looping until all the data has been
00056  * transferred.  These methods also work for sockets in non-blocking
00057  * mode i.e., they keep looping on EWOULDBLOCK.  <timeout> is used
00058  * to make sure we keep making progress, i.e., the same timeout
00059  * value is used for every I/O operation in the loop and the timeout
00060  * is not counted down.
00061  * The return values for the "*_n()" methods match the return values
00062  * from the non "_n()" methods and are specified as follows:
00063  * - On complete transfer, the number of bytes transferred is returned.
00064  * - On timeout, -1 is returned, errno == ETIME.
00065  * - On error, -1 is returned, errno is set to appropriate error.
00066  * - On EOF, 0 is returned, errno is irrelevant.
00067  *
00068  * On partial transfers, i.e., if any data is transferred before
00069  * timeout/error/EOF, <bytes_transferred> will contain the number of
00070  * bytes transferred.
00071  * Methods with <iovec> parameter are I/O vector variants of the I/O
00072  * operations.
00073  * Methods with the extra <flags> argument will always result in
00074  * <send> getting called. Methods without the extra <flags> argument
00075  * will result in <send> getting called on Win32 platforms, and
00076  * <write> getting called on non-Win32 platforms.
00077  */
00078 class ACE_Export ACE_SOCK_SEQPACK_Association : public ACE_SOCK_IO
00079 {
00080 public:
00081   // Initialization and termination methods.
00082   /// Constructor.
00083   ACE_SOCK_SEQPACK_Association (void);
00084 
00085   /// Constructor (sets the underlying ACE_HANDLE with <h>).
00086   ACE_SOCK_SEQPACK_Association (ACE_HANDLE h);
00087 
00088   /// Destructor.
00089   ~ACE_SOCK_SEQPACK_Association (void);
00090 
00091   /**
00092    * Return local endpoint addresses in the referenced array of
00093    * ACE_INET_Addr, which should have the specified <size>.  If the
00094    * number of local endpoint addresses is less than <size>, then
00095    * <size> will be set to this number.  If successful, the method
00096    * returns 0, otherwise returns -1.
00097    */
00098   int get_local_addrs (ACE_INET_Addr *addrs, size_t &size) const;
00099 
00100   /**
00101    * Return remote endpoint addresses in the referenced array of
00102    * ACE_INET_Addr, which should have the specified <size>.  If the
00103    * number of remote endpoint addresses is less than <size>, then
00104    * <size> will be set to this number.  If successful, the method
00105    * returns 0, otherwise returns -1.
00106    */
00107   int get_remote_addrs (ACE_INET_Addr *addrs, size_t &size) const;
00108 
00109   // = I/O functions.
00110 
00111   /// Try to recv exactly <len> bytes into <buf> from the connected socket.
00112   ssize_t recv_n (void *buf,
00113                   size_t len,
00114                   int flags,
00115                   const ACE_Time_Value *timeout = 0,
00116                   size_t *bytes_transferred = 0) const;
00117 
00118   /// Try to recv exactly <len> bytes into <buf> from the connected socket.
00119   ssize_t recv_n (void *buf,
00120                   size_t len,
00121                   const ACE_Time_Value *timeout = 0,
00122                   size_t *bytes_transferred = 0) const;
00123 
00124   /// Receive an <iovec> of size <iovcnt> from the connected socket.
00125   ssize_t recvv_n (iovec iov[],
00126                    int iovcnt,
00127                    const ACE_Time_Value *timeout = 0,
00128                    size_t *bytes_transferred = 0) const;
00129 
00130   /// Try to send exactly <len> bytes from <buf> to the connection socket.
00131   ssize_t send_n (const void *buf,
00132                   size_t len,
00133                   int flags,
00134                   const ACE_Time_Value *timeout = 0,
00135                   size_t *bytes_transferred = 0) const;
00136 
00137   /// Try to send exactly <len> bytes from <buf> to the connected socket.
00138   ssize_t send_n (const void *buf,
00139                   size_t len,
00140                   const ACE_Time_Value *timeout = 0,
00141                   size_t *bytes_transferred = 0) const;
00142 
00143   /// Send all the <message_block>s chained through their <next> and
00144   /// <cont> pointers.  This call uses the underlying OS gather-write
00145   /// operation to reduce the domain-crossing penalty.
00146   ssize_t send_n (const ACE_Message_Block *message_block,
00147                   const ACE_Time_Value *timeout = 0,
00148                   size_t *bytes_transferred = 0) const;
00149 
00150   /// Send an <iovec> of size <iovcnt> to the connected socket.
00151   ssize_t sendv_n (const iovec iov[],
00152                    int iovcnt,
00153                    const ACE_Time_Value *timeout = 0,
00154                    size_t *bytes_transferred = 0) const;
00155 
00156   // = Send/receive ``urgent'' data (see TCP specs...).
00157   ssize_t send_urg (const void *ptr,
00158                     size_t len = sizeof (char),
00159                     const ACE_Time_Value *timeout = 0) const;
00160 
00161   ssize_t recv_urg (void *ptr,
00162                     size_t len = sizeof (char),
00163                     const ACE_Time_Value *timeout = 0) const;
00164 
00165   // = Selectively close endpoints.
00166   /// Close down the reader.
00167   int close_reader (void);
00168 
00169   /// Close down the writer.
00170   int close_writer (void);
00171 
00172   /**
00173    * Close down the socket (we need this to make things work correctly
00174    * on Win32, which requires use to do a <close_writer> before doing
00175    * the close to avoid losing data).  */
00176   int close (void);
00177 
00178   /**
00179    * Abort the association according to RFC 2960 9.1 through the API
00180    * in draft-ietf-tsvwg-sctpsocket-09 7.1.4.
00181    */
00182   int abort (void);
00183 
00184   // = Meta-type info
00185   typedef ACE_Multihomed_INET_Addr PEER_ADDR;
00186 
00187   /// Dump the state of an object.
00188   void dump (void) const;
00189 
00190   /// Declare the dynamic allocation hooks.
00191   ACE_ALLOC_HOOK_DECLARE;
00192 };
00193 
00194 ACE_END_VERSIONED_NAMESPACE_DECL
00195 
00196 #if defined (__ACE_INLINE__)
00197 #include "ace/SOCK_SEQPACK_Association.inl"
00198 #endif /* __ACE_INLINE__ */
00199 
00200 #include /**/ "ace/post.h"
00201 
00202 #endif /* ACE_SOCK_SEQPACK_ASSOCIATION_H */

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