PageRenderTime 46ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/dep/acelite/ace/SOCK_SEQPACK_Association.h

https://bitbucket.org/oregon/oregoncore/
C Header | 199 lines | 68 code | 34 blank | 97 comment | 0 complexity | cf1fff595f7b857b808014647ecbff5d MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, CC-BY-SA-3.0, BSD-2-Clause
  1. // -*- C++ -*-
  2. //=============================================================================
  3. /**
  4. *
  5. * @file SOCK_SEQPACK_Association.h
  6. *
  7. * @author Patrick J. Lardieri <plardier@atl.lmco.com>
  8. * @author Gaurav Naik, Lockheed Martin ATL
  9. * @author based on SOCK_Stream
  10. * by Douglas C. Schmidt <schmidt@cs.wustl.edu>
  11. */
  12. //=============================================================================
  13. #ifndef ACE_SOCK_SEQPACK_ASSOCIATION_H
  14. #define ACE_SOCK_SEQPACK_ASSOCIATION_H
  15. #include /**/ "ace/pre.h"
  16. #include /**/ "ace/ACE_export.h"
  17. #if !defined (ACE_LACKS_PRAGMA_ONCE)
  18. # pragma once
  19. #endif /* ACE_LACKS_PRAGMA_ONCE */
  20. #include "ace/SOCK_IO.h"
  21. #include "ace/Multihomed_INET_Addr.h"
  22. ACE_BEGIN_VERSIONED_NAMESPACE_DECL
  23. // Forward declarations.
  24. class ACE_Message_Block;
  25. /**
  26. * @class ACE_SOCK_SEQPACK_Association
  27. *
  28. * @brief Defines the methods in the ACE_SOCK_SEQPACK_Association abstraction.
  29. *
  30. * This adds additional wrapper methods atop the <ACE_SOCK_IO>
  31. * class.
  32. *
  33. * @a buf is the buffer to write from or receive into.
  34. * @a len is the number of bytes to transfer.
  35. * The @a timeout parameter in the following methods indicates how
  36. * long to blocking trying to transfer data. If @a timeout == 0,
  37. * then the call behaves as a normal send/recv call, i.e., for
  38. * blocking sockets, the call will block until action is possible;
  39. * for non-blocking sockets, EWOULDBLOCK will be returned if no
  40. * action is immediately possible.
  41. * If @a timeout != 0, the call will wait for data to arrive no longer
  42. * than the relative time specified in *@a timeout.
  43. * The "_n()" I/O methods keep looping until all the data has been
  44. * transferred. These methods also work for sockets in non-blocking
  45. * mode i.e., they keep looping on EWOULDBLOCK. @a timeout is used
  46. * to make sure we keep making progress, i.e., the same timeout
  47. * value is used for every I/O operation in the loop and the timeout
  48. * is not counted down.
  49. * The return values for the "*_n()" methods match the return values
  50. * from the non "_n()" methods and are specified as follows:
  51. * - On complete transfer, the number of bytes transferred is returned.
  52. * - On timeout, -1 is returned, errno == ETIME.
  53. * - On error, -1 is returned, errno is set to appropriate error.
  54. * - On EOF, 0 is returned, errno is irrelevant.
  55. *
  56. * On partial transfers, i.e., if any data is transferred before
  57. * timeout/error/EOF, <bytes_transferred> will contain the number of
  58. * bytes transferred.
  59. * Methods with <iovec> parameter are I/O vector variants of the I/O
  60. * operations.
  61. * Methods with the extra @a flags argument will always result in
  62. * <send> getting called. Methods without the extra @a flags argument
  63. * will result in <send> getting called on Win32 platforms, and
  64. * <write> getting called on non-Win32 platforms.
  65. */
  66. class ACE_Export ACE_SOCK_SEQPACK_Association : public ACE_SOCK_IO
  67. {
  68. public:
  69. // Initialization and termination methods.
  70. /// Constructor.
  71. ACE_SOCK_SEQPACK_Association (void);
  72. /// Constructor (sets the underlying ACE_HANDLE with <h>).
  73. ACE_SOCK_SEQPACK_Association (ACE_HANDLE h);
  74. /// Destructor.
  75. ~ACE_SOCK_SEQPACK_Association (void);
  76. /**
  77. * Return local endpoint addresses in the referenced array of
  78. * ACE_INET_Addr, which should have the specified @a size. If the
  79. * number of local endpoint addresses is less than @a size, then
  80. * @a size will be set to this number. If successful, the method
  81. * returns 0, otherwise returns -1.
  82. */
  83. int get_local_addrs (ACE_INET_Addr *addrs, size_t &size) const;
  84. /**
  85. * Return remote endpoint addresses in the referenced array of
  86. * ACE_INET_Addr, which should have the specified @a size. If the
  87. * number of remote endpoint addresses is less than @a size, then
  88. * @a size will be set to this number. If successful, the method
  89. * returns 0, otherwise returns -1.
  90. */
  91. int get_remote_addrs (ACE_INET_Addr *addrs, size_t &size) const;
  92. // = I/O functions.
  93. /// Try to recv exactly @a len bytes into @a buf from the connected socket.
  94. ssize_t recv_n (void *buf,
  95. size_t len,
  96. int flags,
  97. const ACE_Time_Value *timeout = 0,
  98. size_t *bytes_transferred = 0) const;
  99. /// Try to recv exactly @a len bytes into @a buf from the connected socket.
  100. ssize_t recv_n (void *buf,
  101. size_t len,
  102. const ACE_Time_Value *timeout = 0,
  103. size_t *bytes_transferred = 0) const;
  104. /// Receive an <iovec> of size <iovcnt> from the connected socket.
  105. ssize_t recvv_n (iovec iov[],
  106. int iovcnt,
  107. const ACE_Time_Value *timeout = 0,
  108. size_t *bytes_transferred = 0) const;
  109. /// Try to send exactly @a len bytes from @a buf to the connection socket.
  110. ssize_t send_n (const void *buf,
  111. size_t len,
  112. int flags,
  113. const ACE_Time_Value *timeout = 0,
  114. size_t *bytes_transferred = 0) const;
  115. /// Try to send exactly @a len bytes from @a buf to the connected socket.
  116. ssize_t send_n (const void *buf,
  117. size_t len,
  118. const ACE_Time_Value *timeout = 0,
  119. size_t *bytes_transferred = 0) const;
  120. /// Send all the @a message_blocks chained through their <next> and
  121. /// <cont> pointers. This call uses the underlying OS gather-write
  122. /// operation to reduce the domain-crossing penalty.
  123. ssize_t send_n (const ACE_Message_Block *message_block,
  124. const ACE_Time_Value *timeout = 0,
  125. size_t *bytes_transferred = 0) const;
  126. /// Send an <iovec> of size <iovcnt> to the connected socket.
  127. ssize_t sendv_n (const iovec iov[],
  128. int iovcnt,
  129. const ACE_Time_Value *timeout = 0,
  130. size_t *bytes_transferred = 0) const;
  131. // = Send/receive ``urgent'' data (see TCP specs...).
  132. ssize_t send_urg (const void *ptr,
  133. size_t len = sizeof (char),
  134. const ACE_Time_Value *timeout = 0) const;
  135. ssize_t recv_urg (void *ptr,
  136. size_t len = sizeof (char),
  137. const ACE_Time_Value *timeout = 0) const;
  138. // = Selectively close endpoints.
  139. /// Close down the reader.
  140. int close_reader (void);
  141. /// Close down the writer.
  142. int close_writer (void);
  143. /**
  144. * Close down the socket (we need this to make things work correctly
  145. * on Win32, which requires use to do a <close_writer> before doing
  146. * the close to avoid losing data). */
  147. int close (void);
  148. /**
  149. * Abort the association according to RFC 2960 9.1 through the API
  150. * in draft-ietf-tsvwg-sctpsocket-09 7.1.4.
  151. */
  152. int abort (void);
  153. // = Meta-type info
  154. typedef ACE_Multihomed_INET_Addr PEER_ADDR;
  155. /// Dump the state of an object.
  156. void dump (void) const;
  157. /// Declare the dynamic allocation hooks.
  158. ACE_ALLOC_HOOK_DECLARE;
  159. };
  160. ACE_END_VERSIONED_NAMESPACE_DECL
  161. #if defined (__ACE_INLINE__)
  162. #include "ace/SOCK_SEQPACK_Association.inl"
  163. #endif /* __ACE_INLINE__ */
  164. #include /**/ "ace/post.h"
  165. #endif /* ACE_SOCK_SEQPACK_ASSOCIATION_H */