From 8cc4082337bd6ea1be0c9f96d3383314f7fc228b Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Tue, 1 Feb 2011 21:26:00 +0000 Subject: QPID-3007: Unique management identifier for connections. Management was using remote socket address (host:port) to identify connections, but this is not a unique identifier. Both the local and remote addresses are needed to uniquely identify a connection - see http://www.faqs.org/rfcs/rfc793.html. This was causing management errors (multiple objects using same identifier) and cluster failures (invalid-arg exception) due to inconsistencies caused by the incorrect management map. This commit uses "localhost:localport-remotehost:remoteport" as a unique identifier. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1066220 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/sys/Socket.h | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'cpp/src/qpid/sys/Socket.h') diff --git a/cpp/src/qpid/sys/Socket.h b/cpp/src/qpid/sys/Socket.h index 7b50c42a3c..855a8029cc 100644 --- a/cpp/src/qpid/sys/Socket.h +++ b/cpp/src/qpid/sys/Socket.h @@ -10,9 +10,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -60,27 +60,32 @@ public: QPID_COMMON_EXTERN int listen(uint16_t 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 + /** Returns the "socket name" ie the address bound to * the near end of the socket */ QPID_COMMON_EXTERN std::string getSockname() const; - /** Returns the "peer name" ie the address bound to + /** Returns the "peer name" ie the address bound to * the remote end of the socket */ std::string getPeername() const; - /** + /** * Returns an address (host and port) for the remote end of the * socket */ QPID_COMMON_EXTERN std::string getPeerAddress() const; - /** + /** * Returns an address (host and port) for the local end of the * socket */ std::string getLocalAddress() const; + /** + * Returns the full address of the connection: local and remote host and port. + */ + std::string getFullAddress() const { return getLocalAddress()+"-"+getPeerAddress(); } + QPID_COMMON_EXTERN uint16_t getLocalPort() const; uint16_t getRemotePort() const; @@ -95,7 +100,7 @@ public: */ QPID_COMMON_EXTERN Socket* accept() const; - // TODO The following are raw operations, maybe they need better wrapping? + // TODO The following are raw operations, maybe they need better wrapping? QPID_COMMON_EXTERN int read(void *buf, size_t count) const; QPID_COMMON_EXTERN int write(const void *buf, size_t count) const; -- cgit v1.2.1