THRIFT-3062 fix segfault on invalid port number

This closes #425

commit 9d5654389daab6ab6be6bdae110a1acede51e945
Author: Jim King <jim.king@simplivity.com>
Date: 2015-04-04T19:47:34Z
diff --git a/lib/cpp/test/TServerSocketTest.cpp b/lib/cpp/test/TServerSocketTest.cpp
index ebfd03f..eee7c26 100644
--- a/lib/cpp/test/TServerSocketTest.cpp
+++ b/lib/cpp/test/TServerSocketTest.cpp
@@ -21,6 +21,7 @@
 #include <thrift/transport/TSocket.h>
 #include <thrift/transport/TServerSocket.h>
 #include "TestPortFixture.h"
+#include "TTransportCheckThrow.h"
 
 using apache::thrift::transport::TServerSocket;
 using apache::thrift::transport::TSocket;
@@ -51,6 +52,15 @@
     sock2.close();
 }
 
+BOOST_AUTO_TEST_CASE( test_listen_valid_port )
+{
+    TServerSocket sock1(-1);
+    TTRANSPORT_CHECK_THROW(sock1.listen(), TTransportException::BAD_ARGS);
+
+    TServerSocket sock2(65536);
+    TTRANSPORT_CHECK_THROW(sock2.listen(), TTransportException::BAD_ARGS);
+}
+
 BOOST_AUTO_TEST_CASE( test_close_before_listen )
 {
     TServerSocket sock1("localhost", m_serverPort);