qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From astitc...@apache.org
Subject svn commit: r1128064 - in /qpid/trunk/qpid/cpp/src: qpid/broker/ qpid/broker/windows/ qpid/client/ qpid/client/windows/ qpid/sys/ qpid/sys/posix/ qpid/sys/ssl/ qpid/sys/windows/ tests/
Date Thu, 26 May 2011 20:38:17 GMT
Author: astitcher
Date: Thu May 26 20:38:16 2011
New Revision: 1128064

URL: http://svn.apache.org/viewvc?rev=1128064&view=rev
Log:
Refactor socket connect calls to take a string port
This is used used to implement unix domain sockets - QPID-3281

Modified:
    qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp
    qpid/trunk/qpid/cpp/src/qpid/broker/Broker.h
    qpid/trunk/qpid/cpp/src/qpid/broker/Link.cpp
    qpid/trunk/qpid/cpp/src/qpid/broker/windows/SslProtocolFactory.cpp
    qpid/trunk/qpid/cpp/src/qpid/client/ConnectionImpl.cpp
    qpid/trunk/qpid/cpp/src/qpid/client/Connector.h
    qpid/trunk/qpid/cpp/src/qpid/client/RdmaConnector.cpp
    qpid/trunk/qpid/cpp/src/qpid/client/SslConnector.cpp
    qpid/trunk/qpid/cpp/src/qpid/client/TCPConnector.cpp
    qpid/trunk/qpid/cpp/src/qpid/client/TCPConnector.h
    qpid/trunk/qpid/cpp/src/qpid/client/windows/SslConnector.cpp
    qpid/trunk/qpid/cpp/src/qpid/sys/AsynchIO.h
    qpid/trunk/qpid/cpp/src/qpid/sys/ProtocolFactory.h
    qpid/trunk/qpid/cpp/src/qpid/sys/RdmaIOPlugin.cpp
    qpid/trunk/qpid/cpp/src/qpid/sys/Socket.h
    qpid/trunk/qpid/cpp/src/qpid/sys/SslPlugin.cpp
    qpid/trunk/qpid/cpp/src/qpid/sys/TCPIOPlugin.cpp
    qpid/trunk/qpid/cpp/src/qpid/sys/posix/AsynchIO.cpp
    qpid/trunk/qpid/cpp/src/qpid/sys/posix/Socket.cpp
    qpid/trunk/qpid/cpp/src/qpid/sys/ssl/SslIo.cpp
    qpid/trunk/qpid/cpp/src/qpid/sys/ssl/SslIo.h
    qpid/trunk/qpid/cpp/src/qpid/sys/ssl/SslSocket.cpp
    qpid/trunk/qpid/cpp/src/qpid/sys/ssl/SslSocket.h
    qpid/trunk/qpid/cpp/src/qpid/sys/windows/AsynchIO.cpp
    qpid/trunk/qpid/cpp/src/qpid/sys/windows/Socket.cpp
    qpid/trunk/qpid/cpp/src/tests/SocketProxy.h

Modified: qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp?rev=1128064&r1=1128063&r2=1128064&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp Thu May 26 20:38:16 2011
@@ -701,7 +701,7 @@ void Broker::accept() {
 }
 
 void Broker::connect(
-    const std::string& host, uint16_t port, const std::string& transport,
+    const std::string& host, const std::string& port, const std::string& transport,
     boost::function2<void, int, std::string> failed,
     sys::ConnectionCodec::Factory* f)
 {
@@ -717,7 +717,7 @@ void Broker::connect(
 {
     url.throwIfEmpty();
     const Address& addr=url[0];
-    connect(addr.host, addr.port, addr.protocol, failed, f);
+    connect(addr.host, boost::lexical_cast<std::string>(addr.port), addr.protocol,
failed, f);
 }
 
 uint32_t Broker::queueMoveMessages(

Modified: qpid/trunk/qpid/cpp/src/qpid/broker/Broker.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.h?rev=1128064&r1=1128063&r2=1128064&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/Broker.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/Broker.h Thu May 26 20:38:16 2011
@@ -244,7 +244,7 @@ public:
     QPID_BROKER_EXTERN void accept();
 
     /** Create a connection to another broker. */
-    void connect(const std::string& host, uint16_t port,
+    void connect(const std::string& host, const std::string& port,
                  const std::string& transport,
                  boost::function2<void, int, std::string> failed,
                  sys::ConnectionCodec::Factory* =0);

Modified: qpid/trunk/qpid/cpp/src/qpid/broker/Link.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/Link.cpp?rev=1128064&r1=1128063&r2=1128064&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/Link.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/Link.cpp Thu May 26 20:38:16 2011
@@ -117,7 +117,7 @@ void Link::startConnectionLH ()
         // Set the state before calling connect.  It is possible that connect
         // will fail synchronously and call Link::closed before returning.
         setStateLH(STATE_CONNECTING);
-        broker->connect (host, port, transport,
+        broker->connect (host, boost::lexical_cast<std::string>(port), transport,
                          boost::bind (&Link::closed, this, _1, _2));
         QPID_LOG (debug, "Inter-broker link connecting to " << host << ":" <<
port);
     } catch(std::exception& e) {

Modified: qpid/trunk/qpid/cpp/src/qpid/broker/windows/SslProtocolFactory.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/windows/SslProtocolFactory.cpp?rev=1128064&r1=1128063&r2=1128064&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/windows/SslProtocolFactory.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/windows/SslProtocolFactory.cpp Thu May 26 20:38:16
2011
@@ -81,7 +81,7 @@ class SslProtocolFactory : public qpid::
     SslProtocolFactory(const SslServerOptions&, int backlog, bool nodelay);
     ~SslProtocolFactory();
     void accept(sys::Poller::shared_ptr, sys::ConnectionCodec::Factory*);
-    void connect(sys::Poller::shared_ptr, const std::string& host, int16_t port,
+    void connect(sys::Poller::shared_ptr, const std::string& host, const std::string&
port,
                  sys::ConnectionCodec::Factory*,
                  ConnectFailedCallback failed);
 
@@ -130,7 +130,7 @@ SslProtocolFactory::SslProtocolFactory(c
                                        int backlog,
                                        bool nodelay)
     : tcpNoDelay(nodelay),
-      listeningPort(listener.listen(options.port, backlog)),
+    listeningPort(listener.listen("", boost::lexical_cast<std::string>(options.port),
backlog)),
       clientAuthSelected(options.clientAuth) {
 
     SecInvalidateHandle(&credHandle);
@@ -251,7 +251,7 @@ void SslProtocolFactory::accept(sys::Pol
 
 void SslProtocolFactory::connect(sys::Poller::shared_ptr poller,
                                  const std::string& host,
-                                 int16_t port,
+                                 const std::string& port,
                                  sys::ConnectionCodec::Factory* fact,
                                  ConnectFailedCallback failed)
 {

Modified: qpid/trunk/qpid/cpp/src/qpid/client/ConnectionImpl.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/client/ConnectionImpl.cpp?rev=1128064&r1=1128063&r2=1128064&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/client/ConnectionImpl.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/client/ConnectionImpl.cpp Thu May 26 20:38:16 2011
@@ -36,6 +36,7 @@
 
 #include <boost/bind.hpp>
 #include <boost/format.hpp>
+#include <boost/lexical_cast.hpp>
 #include <boost/shared_ptr.hpp>
 
 #include <limits>
@@ -258,8 +259,9 @@ void ConnectionImpl::open()
     connector->setInputHandler(&handler);
     connector->setShutdownHandler(this);
     try {
-        connector->connect(host, port);
-    
+        std::string p = boost::lexical_cast<std::string>(port);
+        connector->connect(host, p);
+
     } catch (const std::exception& e) {
         QPID_LOG(debug, "Failed to connect to " << protocol << ":" << host
<< ":" << port << " " << e.what());
         connector.reset();
@@ -267,7 +269,7 @@ void ConnectionImpl::open()
     }
     connector->init();
     QPID_LOG(info, *this << " connected to " << protocol << ":" <<
host << ":" << port);
- 
+
     // Enable heartbeat if requested
     uint16_t heartbeat = static_cast<ConnectionSettings&>(handler).heartbeat;
     if (heartbeat) {

Modified: qpid/trunk/qpid/cpp/src/qpid/client/Connector.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/client/Connector.h?rev=1128064&r1=1128063&r2=1128064&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/client/Connector.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/client/Connector.h Thu May 26 20:38:16 2011
@@ -61,7 +61,7 @@ class Connector : public framing::Output
     static void registerFactory(const std::string& proto, Factory* connectorFactory);
 
     virtual ~Connector() {};
-    virtual void connect(const std::string& host, int port) = 0;
+    virtual void connect(const std::string& host, const std::string& port) = 0;
     virtual void init() {};
     virtual void close() = 0;
     virtual void send(framing::AMQFrame& frame) = 0;

Modified: qpid/trunk/qpid/cpp/src/qpid/client/RdmaConnector.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/client/RdmaConnector.cpp?rev=1128064&r1=1128063&r2=1128064&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/client/RdmaConnector.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/client/RdmaConnector.cpp Thu May 26 20:38:16 2011
@@ -95,7 +95,7 @@ class RdmaConnector : public Connector, 
 
     std::string identifier;
 
-    void connect(const std::string& host, int port);
+    void connect(const std::string& host, const std::string& port);
     void close();
     void send(framing::AMQFrame& frame);
     void abort() {} // TODO: need to fix this for heartbeat timeouts to work
@@ -173,7 +173,7 @@ RdmaConnector::~RdmaConnector() {
     }
 }
 
-void RdmaConnector::connect(const std::string& host, int port){
+void RdmaConnector::connect(const std::string& host, const std::string& port){
     Mutex::ScopedLock l(dataConnectedLock);
     assert(!dataConnected);
 
@@ -184,7 +184,7 @@ void RdmaConnector::connect(const std::s
         boost::bind(&RdmaConnector::disconnected, this),
         boost::bind(&RdmaConnector::rejected, this, poller, _1, _2));
 
-    SocketAddress sa(host, boost::lexical_cast<std::string>(port));
+    SocketAddress sa(host, port);
     acon->start(poller, sa);
 }
 

Modified: qpid/trunk/qpid/cpp/src/qpid/client/SslConnector.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/client/SslConnector.cpp?rev=1128064&r1=1128063&r2=1128064&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/client/SslConnector.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/client/SslConnector.cpp Thu May 26 20:38:16 2011
@@ -114,7 +114,7 @@ class SslConnector : public Connector
 
     std::string identifier;
 
-    void connect(const std::string& host, int port);
+    void connect(const std::string& host, const std::string& port);
     void init();
     void close();
     void send(framing::AMQFrame& frame);
@@ -190,7 +190,7 @@ SslConnector::~SslConnector() {
     close();
 }
 
-void SslConnector::connect(const std::string& host, int port){
+void SslConnector::connect(const std::string& host, const std::string& port){
     Mutex::ScopedLock l(closedLock);
     assert(closed);
     try {

Modified: qpid/trunk/qpid/cpp/src/qpid/client/TCPConnector.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/client/TCPConnector.cpp?rev=1128064&r1=1128063&r2=1128064&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/client/TCPConnector.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/client/TCPConnector.cpp Thu May 26 20:38:16 2011
@@ -88,7 +88,7 @@ TCPConnector::~TCPConnector() {
     close();
 }
 
-void TCPConnector::connect(const std::string& host, int port) {
+void TCPConnector::connect(const std::string& host, const std::string& port) {
     Mutex::ScopedLock l(lock);
     assert(closed);
     connector = AsynchConnector::create(

Modified: qpid/trunk/qpid/cpp/src/qpid/client/TCPConnector.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/client/TCPConnector.h?rev=1128064&r1=1128063&r2=1128064&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/client/TCPConnector.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/client/TCPConnector.h Thu May 26 20:38:16 2011
@@ -98,7 +98,7 @@ class TCPConnector : public Connector, p
 
 protected:
     virtual ~TCPConnector();
-    void connect(const std::string& host, int port);
+    void connect(const std::string& host, const std::string& port);
     void start(sys::AsynchIO* aio_);
     void initAmqp();
     virtual void connectFailed(const std::string& msg);

Modified: qpid/trunk/qpid/cpp/src/qpid/client/windows/SslConnector.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/client/windows/SslConnector.cpp?rev=1128064&r1=1128063&r2=1128064&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/client/windows/SslConnector.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/client/windows/SslConnector.cpp Thu May 26 20:38:16 2011
@@ -77,7 +77,7 @@ public:
                  framing::ProtocolVersion pVersion,
                  const ConnectionSettings&, 
                  ConnectionImpl*);
-    virtual void connect(const std::string& host, int port);
+    virtual void connect(const std::string& host, const std::string& port);
     virtual void connected(const Socket&);
     unsigned int getSSF();
 };
@@ -153,7 +153,7 @@ SslConnector::~SslConnector()
 
   // Will this get reach via virtual method via boost::bind????
 
-void SslConnector::connect(const std::string& host, int port) {
+void SslConnector::connect(const std::string& host, const std::string& port) {
     brokerHost = host;
     TCPConnector::connect(host, port);
 }

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/AsynchIO.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/AsynchIO.h?rev=1128064&r1=1128063&r2=1128064&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/AsynchIO.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/AsynchIO.h Thu May 26 20:38:16 2011
@@ -64,8 +64,8 @@ public:
     // deletes. To correctly manage heaps when needed, the allocate and
     // delete should both be done from the same class/library.
     QPID_COMMON_EXTERN static AsynchConnector* create(const Socket& s,
-                                   std::string hostname,
-                                   uint16_t port,
+                                   const std::string& hostname,
+                                   const std::string& port,
                                    ConnectedCallback connCb,
                                    FailedCallback failCb);
     virtual void start(boost::shared_ptr<Poller> poller) = 0;

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/ProtocolFactory.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/ProtocolFactory.h?rev=1128064&r1=1128063&r2=1128064&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/ProtocolFactory.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/ProtocolFactory.h Thu May 26 20:38:16 2011
@@ -43,7 +43,7 @@ class ProtocolFactory : public qpid::Sha
     virtual void accept(boost::shared_ptr<Poller>, ConnectionCodec::Factory*) = 0;
     virtual void connect(
         boost::shared_ptr<Poller>,
-        const std::string& host, int16_t port,
+        const std::string& host, const std::string& port,
         ConnectionCodec::Factory* codec,
         ConnectFailedCallback failed) = 0;
     virtual bool supports(const std::string& /*capability*/) { return false; }

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/RdmaIOPlugin.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/RdmaIOPlugin.cpp?rev=1128064&r1=1128063&r2=1128064&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/RdmaIOPlugin.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/RdmaIOPlugin.cpp Thu May 26 20:38:16 2011
@@ -31,7 +31,6 @@
 #include "qpid/sys/SecuritySettings.h"
 
 #include <boost/bind.hpp>
-#include <boost/lexical_cast.hpp>
 #include <memory>
 
 #include <netdb.h>
@@ -254,7 +253,7 @@ class RdmaIOProtocolFactory : public Pro
   public:
     RdmaIOProtocolFactory(int16_t port, int backlog);
     void accept(Poller::shared_ptr, ConnectionCodec::Factory*);
-    void connect(Poller::shared_ptr, const string& host, int16_t port, ConnectionCodec::Factory*,
ConnectFailedCallback);
+    void connect(Poller::shared_ptr, const string& host, const std::string& port,
ConnectionCodec::Factory*, ConnectFailedCallback);
 
     uint16_t getPort() const;
     string getHost() const;
@@ -387,7 +386,7 @@ void RdmaIOProtocolFactory::connected(Po
 
 void RdmaIOProtocolFactory::connect(
     Poller::shared_ptr poller,
-    const std::string& host, int16_t port,
+    const std::string& host, const std::string& port,
     ConnectionCodec::Factory* f,
     ConnectFailedCallback failed)
 {
@@ -399,7 +398,7 @@ void RdmaIOProtocolFactory::connect(
             boost::bind(&RdmaIOProtocolFactory::disconnected, this, _1),
             boost::bind(&RdmaIOProtocolFactory::rejected, this, _1, _2, failed));
 
-    SocketAddress sa(host, boost::lexical_cast<std::string>(port));
+    SocketAddress sa(host, port);
     c->start(poller, sa);
 }
 

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/Socket.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/Socket.h?rev=1128064&r1=1128063&r2=1128064&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/Socket.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/Socket.h Thu May 26 20:38:16 2011
@@ -47,7 +47,7 @@ public:
 
     QPID_COMMON_EXTERN void setTcpNoDelay() const;
 
-    QPID_COMMON_EXTERN void connect(const std::string& host, uint16_t port) const;
+    QPID_COMMON_EXTERN void connect(const std::string& host, const std::string& port)
const;
     QPID_COMMON_EXTERN void connect(const SocketAddress&) const;
 
     QPID_COMMON_EXTERN void close() const;
@@ -57,7 +57,7 @@ public:
      *@param backlog maximum number of pending connections.
      *@return The bound port.
      */
-    QPID_COMMON_EXTERN int listen(uint16_t port = 0, int backlog = 10) const;
+    QPID_COMMON_EXTERN int listen(const std::string& host = "", const std::string&
port = "0", int backlog = 10) const;
     QPID_COMMON_EXTERN int listen(const SocketAddress&, int backlog = 10) const;
 
     /** Returns the "socket name" ie the address bound to

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/SslPlugin.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/SslPlugin.cpp?rev=1128064&r1=1128063&r2=1128064&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/SslPlugin.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/SslPlugin.cpp Thu May 26 20:38:16 2011
@@ -66,7 +66,7 @@ class SslProtocolFactory : public Protoc
   public:
     SslProtocolFactory(const SslServerOptions&, int backlog, bool nodelay);
     void accept(Poller::shared_ptr, ConnectionCodec::Factory*);
-    void connect(Poller::shared_ptr, const std::string& host, int16_t port,
+    void connect(Poller::shared_ptr, const std::string& host, const std::string&
port,
                  ConnectionCodec::Factory*,
                  boost::function2<void, int, std::string> failed);
 
@@ -160,7 +160,7 @@ void SslProtocolFactory::accept(Poller::
 
 void SslProtocolFactory::connect(
     Poller::shared_ptr poller,
-    const std::string& host, int16_t port,
+    const std::string& host, const std::string& port,
     ConnectionCodec::Factory* fact,
     ConnectFailedCallback failed)
 {

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/TCPIOPlugin.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/TCPIOPlugin.cpp?rev=1128064&r1=1128063&r2=1128064&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/TCPIOPlugin.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/TCPIOPlugin.cpp Thu May 26 20:38:16 2011
@@ -42,9 +42,9 @@ class AsynchIOProtocolFactory : public P
     std::auto_ptr<AsynchAcceptor> acceptor;
 
   public:
-    AsynchIOProtocolFactory(int16_t port, int backlog, bool nodelay);
+    AsynchIOProtocolFactory(const std::string& host, const std::string& port, int
backlog, bool nodelay);
     void accept(Poller::shared_ptr, ConnectionCodec::Factory*);
-    void connect(Poller::shared_ptr, const std::string& host, int16_t port,
+    void connect(Poller::shared_ptr, const std::string& host, const std::string&
port,
                  ConnectionCodec::Factory*,
                  ConnectFailedCallback);
 
@@ -61,22 +61,25 @@ class AsynchIOProtocolFactory : public P
 static class TCPIOPlugin : public Plugin {
     void earlyInitialize(Target&) {
     }
-    
+
     void initialize(Target& target) {
         broker::Broker* broker = dynamic_cast<broker::Broker*>(&target);
         // Only provide to a Broker
         if (broker) {
             const broker::Broker::Options& opts = broker->getOptions();
-            ProtocolFactory::shared_ptr protocol(new AsynchIOProtocolFactory(opts.port, opts.connectionBacklog,

-                                                                             opts.tcpNoDelay));
-            QPID_LOG(notice, "Listening on TCP port " << protocol->getPort());
-            broker->registerProtocolFactory("tcp", protocol);
+            ProtocolFactory::shared_ptr protocolt(
+                new AsynchIOProtocolFactory(
+                    "", boost::lexical_cast<std::string>(opts.port),
+                    opts.connectionBacklog,
+                    opts.tcpNoDelay));
+            QPID_LOG(notice, "Listening on TCP port " << protocolt->getPort());
+            broker->registerProtocolFactory("tcp", protocolt);
         }
     }
 } tcpPlugin;
 
-AsynchIOProtocolFactory::AsynchIOProtocolFactory(int16_t port, int backlog, bool nodelay)
:
-    tcpNoDelay(nodelay), listeningPort(listener.listen(port, backlog))
+AsynchIOProtocolFactory::AsynchIOProtocolFactory(const std::string& host, const std::string&
port, int backlog, bool nodelay) :
+    tcpNoDelay(nodelay), listeningPort(listener.listen(host, port, backlog))
 {}
 
 void AsynchIOProtocolFactory::established(Poller::shared_ptr poller, const Socket& s,
@@ -130,7 +133,7 @@ void AsynchIOProtocolFactory::connectFai
 
 void AsynchIOProtocolFactory::connect(
     Poller::shared_ptr poller,
-    const std::string& host, int16_t port,
+    const std::string& host, const std::string& port,
     ConnectionCodec::Factory* fact,
     ConnectFailedCallback failed)
 {
@@ -139,7 +142,6 @@ void AsynchIOProtocolFactory::connect(
     // upon connection failure or by the AsynchIO upon connection
     // shutdown.  The allocated AsynchConnector frees itself when it
     // is no longer needed.
-
     Socket* socket = new Socket();
     AsynchConnector* c = AsynchConnector::create(
         *socket,

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/posix/AsynchIO.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/posix/AsynchIO.cpp?rev=1128064&r1=1128063&r2=1128064&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/posix/AsynchIO.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/posix/AsynchIO.cpp Thu May 26 20:38:16 2011
@@ -152,8 +152,8 @@ private:
 
 public:
     AsynchConnector(const Socket& socket,
-                    std::string hostname,
-                    uint16_t port,
+                    const std::string& hostname,
+                    const std::string& port,
                     ConnectedCallback connCb,
                     FailedCallback failCb);
     void start(Poller::shared_ptr poller);
@@ -161,8 +161,8 @@ public:
 };
 
 AsynchConnector::AsynchConnector(const Socket& s,
-                                 std::string hostname,
-                                 uint16_t port,
+                                 const std::string& hostname,
+                                 const std::string& port,
                                  ConnectedCallback connCb,
                                  FailedCallback failCb) :
     DispatchHandle(s,
@@ -174,7 +174,7 @@ AsynchConnector::AsynchConnector(const S
     socket(s)
 {
     socket.setNonblocking();
-    SocketAddress sa(hostname, boost::lexical_cast<std::string>(port));
+    SocketAddress sa(hostname, port);
     // Note, not catching any exceptions here, also has effect of destructing
     socket.connect(sa);
 }
@@ -589,8 +589,8 @@ AsynchAcceptor* AsynchAcceptor::create(c
 }
 
 AsynchConnector* AsynchConnector::create(const Socket& s,
-                                         std::string hostname,
-                                         uint16_t port,
+                                         const std::string& hostname,
+                                         const std::string& port,
                                          ConnectedCallback connCb,
                                          FailedCallback failCb)
 {

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/posix/Socket.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/posix/Socket.cpp?rev=1128064&r1=1128063&r2=1128064&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/posix/Socket.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/posix/Socket.cpp Thu May 26 20:38:16 2011
@@ -37,7 +37,6 @@
 #include <iostream>
 
 #include <boost/format.hpp>
-#include <boost/lexical_cast.hpp>
 
 namespace qpid {
 namespace sys {
@@ -154,9 +153,9 @@ void Socket::setTcpNoDelay() const
     }
 }
 
-void Socket::connect(const std::string& host, uint16_t port) const
+void Socket::connect(const std::string& host, const std::string& port) const
 {
-    SocketAddress sa(host, boost::lexical_cast<std::string>(port));
+    SocketAddress sa(host, port);
     connect(sa);
 }
 
@@ -200,9 +199,9 @@ Socket::close() const
     socket = -1;
 }
 
-int Socket::listen(uint16_t port, int backlog) const
+int Socket::listen(const std::string& host, const std::string& port, int backlog)
const
 {
-    SocketAddress sa("", boost::lexical_cast<std::string>(port));
+    SocketAddress sa(host, port);
     return listen(sa, backlog);
 }
 

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/ssl/SslIo.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/ssl/SslIo.cpp?rev=1128064&r1=1128063&r2=1128064&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/ssl/SslIo.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/ssl/SslIo.cpp Thu May 26 20:38:16 2011
@@ -117,7 +117,7 @@ void SslAcceptor::readable(DispatchHandl
 SslConnector::SslConnector(const SslSocket& s,
                                  Poller::shared_ptr poller,
                                  std::string hostname,
-                                 uint16_t port,
+                                 std::string port,
                                  ConnectedCallback connCb,
                                  FailedCallback failCb) :
     DispatchHandle(s,

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/ssl/SslIo.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/ssl/SslIo.h?rev=1128064&r1=1128063&r2=1128064&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/ssl/SslIo.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/ssl/SslIo.h Thu May 26 20:38:16 2011
@@ -73,7 +73,7 @@ public:
     SslConnector(const SslSocket& socket,
                     Poller::shared_ptr poller,
                     std::string hostname,
-                    uint16_t port,
+                    std::string port,
                     ConnectedCallback connCb,
                     FailedCallback failCb = 0);
 

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/ssl/SslSocket.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/ssl/SslSocket.cpp?rev=1128064&r1=1128063&r2=1128064&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/ssl/SslSocket.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/ssl/SslSocket.cpp Thu May 26 20:38:16 2011
@@ -158,7 +158,7 @@ void SslSocket::setNonblocking() const
     PR_SetSocketOption(socket, &option);
 }
 
-void SslSocket::connect(const std::string& host, uint16_t port) const
+void SslSocket::connect(const std::string& host, const std::string& port) const
 {
     std::stringstream namestream;
     namestream << host << ":" << port;
@@ -180,7 +180,7 @@ void SslSocket::connect(const std::strin
     PRHostEnt hostEntry;
     PR_CHECK(PR_GetHostByName(host.data(), hostBuffer, PR_NETDB_BUF_SIZE, &hostEntry));
     PRNetAddr address;
-    int value = PR_EnumerateHostEnt(0, &hostEntry, port, &address);
+    int value = PR_EnumerateHostEnt(0, &hostEntry, boost::lexical_cast<PRUint16>(port),
&address);
     if (value < 0) {
         throw Exception(QPID_MSG("Error getting address for host: " << ErrorString()));
     } else if (value == 0) {

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/ssl/SslSocket.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/ssl/SslSocket.h?rev=1128064&r1=1128063&r2=1128064&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/ssl/SslSocket.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/ssl/SslSocket.h Thu May 26 20:38:16 2011
@@ -53,7 +53,7 @@ public:
      * NSSInit().*/
     void setCertName(const std::string& certName);
 
-    void connect(const std::string& host, uint16_t port) const;
+    void connect(const std::string& host, const std::string& port) const;
 
     void close() const;
 

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/windows/AsynchIO.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/windows/AsynchIO.cpp?rev=1128064&r1=1128063&r2=1128064&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/windows/AsynchIO.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/windows/AsynchIO.cpp Thu May 26 20:38:16 2011
@@ -175,20 +175,20 @@ private:
     FailedCallback failCallback;
     const Socket& socket;
     const std::string hostname;
-    const uint16_t port;
+    const std::string port;
 
 public:
     AsynchConnector(const Socket& socket,
-                    std::string hostname,
-                    uint16_t port,
+                    const std::string& hostname,
+                    const std::string& port,
                     ConnectedCallback connCb,
                     FailedCallback failCb = 0);
     void start(Poller::shared_ptr poller);
 };
 
 AsynchConnector::AsynchConnector(const Socket& sock,
-                                 std::string hname,
-                                 uint16_t p,
+                                 const std::string& hname,
+                                 const std::string& p,
                                  ConnectedCallback connCb,
                                  FailedCallback failCb) :
     connCallback(connCb), failCallback(failCb), socket(sock),
@@ -218,8 +218,8 @@ AsynchAcceptor* AsynchAcceptor::create(c
 }
 
 AsynchConnector* qpid::sys::AsynchConnector::create(const Socket& s,
-                                                    std::string hostname,
-                                                    uint16_t port,
+                                                    const std::string& hostname,
+                                                    const std::string& port,
                                                     ConnectedCallback connCb,
                                                     FailedCallback failCb)
 {

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/windows/Socket.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/windows/Socket.cpp?rev=1128064&r1=1128063&r2=1128064&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/windows/Socket.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/windows/Socket.cpp Thu May 26 20:38:16 2011
@@ -89,7 +89,7 @@ namespace sys {
 
 namespace {
 
-std::string getName(SOCKET fd, bool local, bool includeService = false)
+std::string getName(SOCKET fd, bool local)
 {
     sockaddr_in name; // big enough for any socket address    
     socklen_t namelen = sizeof(name);
@@ -198,9 +198,9 @@ void Socket::setNonblocking() const {
     QPID_WINSOCK_CHECK(ioctlsocket(impl->fd, FIONBIO, &nonblock));
 }
 
-void Socket::connect(const std::string& host, uint16_t port) const
+void Socket::connect(const std::string& host, const std::string& port) const
 {
-    SocketAddress sa(host, boost::lexical_cast<std::string>(port));
+    SocketAddress sa(host, port);
     connect(sa);
 }
 
@@ -252,7 +252,7 @@ int Socket::read(void *buf, size_t count
     return received;
 }
 
-int Socket::listen(uint16_t port, int backlog) const
+int Socket::listen(const std::string&, const std::string& port, int backlog) const
 {
     const SOCKET& socket = impl->fd;
     BOOL yes=1;
@@ -260,7 +260,7 @@ int Socket::listen(uint16_t port, int ba
     struct sockaddr_in name;
     memset(&name, 0, sizeof(name));
     name.sin_family = AF_INET;
-    name.sin_port = htons(port);
+    name.sin_port = htons(boost::lexical_cast<uint16_t>(port));
     name.sin_addr.s_addr = 0;
     if (::bind(socket, (struct sockaddr*)&name, sizeof(name)) == SOCKET_ERROR)
         throw Exception(QPID_MSG("Can't bind to port " << port << ": " <<
strError(WSAGetLastError())));

Modified: qpid/trunk/qpid/cpp/src/tests/SocketProxy.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/SocketProxy.h?rev=1128064&r1=1128063&r2=1128064&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/SocketProxy.h (original)
+++ qpid/trunk/qpid/cpp/src/tests/SocketProxy.h Thu May 26 20:38:16 2011
@@ -35,6 +35,8 @@
 #include "qpid/sys/Mutex.h"
 #include "qpid/log/Statement.h"
 
+#include <boost/lexical_cast.hpp>
+
 namespace qpid {
 namespace tests {
 
@@ -62,7 +64,7 @@ class SocketProxy : private qpid::sys::R
       : closed(false), joined(true),
         port(listener.listen()), dropClient(), dropServer()
     {
-        client.connect(host, connectPort);
+        client.connect(host, boost::lexical_cast<std::string>(connectPort));
         joined = false;
         thread = qpid::sys::Thread(static_cast<qpid::sys::Runnable*>(this));
     }



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message