albertogpz commented on a change in pull request #697:
URL: https://github.com/apache/geode-native/pull/697#discussion_r542255519



##########
File path: cppcache/src/Connector.hpp
##########
@@ -63,45 +67,88 @@ class Connector {
    *
    * @param      b   the buffer into which the data is read.
    * @param      len   the number of bytes to read.
-   * @param      waitSeconds   the number of seconds to allow the read to
-   * complete.
+   * @param      timeout time to allow the read to complete.
    * @return     the total number of bytes read into the buffer, or
    *             <code>-1</code> if an error was encountered.
    * @exception  GeodeIOException, TimeoutException, IllegalArgumentException,
    * OutOfMemoryException.
    */
   virtual size_t receive(char *b, size_t len,
-                         std::chrono::microseconds waitSeconds) = 0;
+                         std::chrono::milliseconds timeout) = 0;
 
+  /**
+   * Reads an undetermined number of bytes of data and stores them into the
+   * buffer array <code>b</code>. The number of bytes actually read is returned
+   * as an integer.  This method blocks until <code>len</code> bytes of data is
+   * read, the timeout expires or an exception is thrown.
+   *
+   * <p> If <code>b</code> is <code>null</code> an
+   * <code>IllegalArgumentException</code>
+   * is thrown.
+   *
+   * <p> The <code>read(b)</code> method for class <code>InputStream</code>
+   * has the same effect as: <pre><code> read(b, 0, b.length) </code></pre>
+   *
+   * @param      b   the buffer into which the data is read.
+   * @param      timeout time to allow the read to complete.
+   * @return     the total number of bytes read into the buffer, or
+   *             <code>-1</code> if an error was encountered.
+   * @exception  GeodeIOException, IllegalArgumentException,
+   * OutOfMemoryException.
+   */
+  virtual size_t receive_nothrowiftimeout(
+      char *b, size_t len, std::chrono::milliseconds timeout) = 0;
   /**
    * Writes <code>len</code> bytes from the specified byte array
    * to the underlying output stream.
    *
    * @param      b     the data.
    * @param      len   the number of bytes to write.
-   * @param      waitSeconds   the number of seconds to allow the write to
-   * complete.
+   * @param      timeout time to allow the write to complete.
    * @return     the actual number of bytes written.
    * @exception  GeodeIOException, TimeoutException, IllegalArgumentException.
    */
   virtual size_t send(const char *b, size_t len,
-                      std::chrono::microseconds waitSeconds) = 0;
+                      std::chrono::milliseconds timeout) = 0;
 
   /**
-   * Initialises the connection.
+   * Returns local port for this TCP connection
    */
-  virtual void init() = 0;
+  virtual uint16_t getPort() = 0;
 
   /**
-   * Closes the connection.
+   * Writes an array of a known size to the underlying output stream.
+   *
+   * @param   array A C-style stack array. Be weary of arrays that have been
+   * decayed into pointers, they won't compile.
+   * @return  The number of bytes written. Don't get confused: this is not the
+   * number of elements in the array written.
+   * @exception GeodeIOException, TimeoutException
    */
-  virtual void close() = 0;
+  template <typename T, size_t size>
+  size_t send(const T (&array)[size], std::chrono::milliseconds timeout) {
+    return send(reinterpret_cast<const char *>(array), sizeof(T) * size,
+                timeout);
+  }
 
   /**
-   * Returns local port for this TCP connection
+   * Reads an array of a known size from the underlying input stream. If the
+   * number of bytes read is not equal to the size of the array, no exception
+   * will be thrown.
+   *
+   * @param   array A C-style stack array. Be weary of arrays that have been
+   * decayed into pointers, they won't compile.
+   * @return  The number of bytes written. Don't get confused: this is not the
+   * number of elements in the array written.
+   * @exception GeodeIOException
    */
-  virtual uint16_t getPort() = 0;
+  template <typename T, size_t size>
+  size_t receive(T (&array)[size], std::chrono::milliseconds timeout) {
+    return receive_nothrowiftimeout(reinterpret_cast<char *>(array),
+                                    sizeof(T) * size, timeout);
+  }

Review comment:
       Class not finally exported.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to