THRIFT-928. cpp: TNonblockingServer: use TSocket and support TClientInfo

Modify TNonblockingServer to use TSocket for I/O and support server
event handlers; this enables TClientInfo to function with a minor change
to the processing loop.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005145 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/transport/TSocket.h b/lib/cpp/src/transport/TSocket.h
index 97562c2..e89059f 100644
--- a/lib/cpp/src/transport/TSocket.h
+++ b/lib/cpp/src/transport/TSocket.h
@@ -95,11 +95,16 @@
   uint32_t read(uint8_t* buf, uint32_t len);
 
   /**
-   * Writes to the underlying socket.
+   * Writes to the underlying socket.  Loops until done or fail.
    */
   void write(const uint8_t* buf, uint32_t len);
 
   /**
+   * Writes to the underlying socket.  Does single send() and returns result.
+   */
+  uint32_t write_partial(const uint8_t* buf, uint32_t len);
+
+  /**
    * Get the host that the socket is connected to
    *
    * @return string host identifier
@@ -191,6 +196,15 @@
     return socket_;
   }
 
+  /**
+   * (Re-)initialize a TSocket for the supplied descriptor.  This is only
+   * intended for use by TNonblockingServer -- other use may result in
+   * unfortunate surprises.
+   *
+   * @param fd the descriptor for an already-connected socket
+   */
+  void setSocketFD(int fd);
+
   /*
    * Returns a cached copy of the peer address.
    */
@@ -211,16 +225,16 @@
    */
   TSocket(int socket);
 
- protected:
-  /** connect, called by open */
-  void openConnection(struct addrinfo *res);
-
   /**
    * Set a cache of the peer address (used when trivially available: e.g.
    * accept() or connect()). Only caches IPV4 and IPV6; unset for others.
    */
   void setCachedAddress(const sockaddr* addr, socklen_t len);
 
+ protected:
+  /** connect, called by open */
+  void openConnection(struct addrinfo *res);
+
   /** Host to connect to */
   std::string host_;