THRIFT-756. cpp: Exposing TSocket(int) constructor to public

This patch changes the raw socket handle constructor from protected to public.

Patch: Rajat Goel

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@991785 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/transport/TSocket.cpp b/lib/cpp/src/transport/TSocket.cpp
index ce1ddcb..5da33bb 100644
--- a/lib/cpp/src/transport/TSocket.cpp
+++ b/lib/cpp/src/transport/TSocket.cpp
@@ -127,7 +127,7 @@
 
 void TSocket::openConnection(struct addrinfo *res) {
   if (isOpen()) {
-    throw TTransportException(TTransportException::ALREADY_OPEN);
+    return;
   }
 
   socket_ = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
@@ -235,7 +235,7 @@
 
 void TSocket::open() {
   if (isOpen()) {
-    throw TTransportException(TTransportException::ALREADY_OPEN);
+    return;
   }
 
   // Validate port number
diff --git a/lib/cpp/src/transport/TSocket.h b/lib/cpp/src/transport/TSocket.h
index 70c167f..0184362 100644
--- a/lib/cpp/src/transport/TSocket.h
+++ b/lib/cpp/src/transport/TSocket.h
@@ -193,13 +193,12 @@
    */
   static bool getUseLowMinRto();
 
- protected:
   /**
-   * Constructor to create socket from raw UNIX handle. Never called directly
-   * but used by the TServerSocket class.
+   * Constructor to create socket from raw UNIX handle.
    */
   TSocket(int socket);
 
+ protected:
   /** connect, called by open */
   void openConnection(struct addrinfo *res);
 
diff --git a/lib/cpp/src/transport/TTransportException.h b/lib/cpp/src/transport/TTransportException.h
index a3ad02b..e0630ef 100644
--- a/lib/cpp/src/transport/TTransportException.h
+++ b/lib/cpp/src/transport/TTransportException.h
@@ -41,13 +41,12 @@
   enum TTransportExceptionType
   { UNKNOWN = 0
   , NOT_OPEN = 1
-  , ALREADY_OPEN = 2
-  , TIMED_OUT = 3
-  , END_OF_FILE = 4
-  , INTERRUPTED = 5
-  , BAD_ARGS = 6
-  , CORRUPTED_DATA = 7
-  , INTERNAL_ERROR = 8
+  , TIMED_OUT = 2
+  , END_OF_FILE = 3
+  , INTERRUPTED = 4
+  , BAD_ARGS = 5
+  , CORRUPTED_DATA = 6
+  , INTERNAL_ERROR = 7
   };
 
   TTransportException() :
@@ -89,7 +88,6 @@
       switch (type_) {
         case UNKNOWN        : return "TTransportException: Unknown transport exception";
         case NOT_OPEN       : return "TTransportException: Transport not open";
-        case ALREADY_OPEN   : return "TTransportException: Transport already open";
         case TIMED_OUT      : return "TTransportException: Timed out";
         case END_OF_FILE    : return "TTransportException: End of file";
         case INTERRUPTED    : return "TTransportException: Interrupted";