Index: source/ariba/communication/BaseCommunication.cpp
===================================================================
--- source/ariba/communication/BaseCommunication.cpp	(revision 5508)
+++ source/ariba/communication/BaseCommunication.cpp	(revision 5614)
@@ -56,4 +56,34 @@
 use_logging_cpp(BaseCommunication);
 
+/// adds an endpoint to the list
+void BaseCommunication::add_endpoint( const address_v* endpoint ) {
+	BOOST_FOREACH( endpoint_reference& ref, remote_endpoints ) {
+		if (*ref.endpoint == *endpoint) {
+			ref.count++;
+			return;
+		}
+	}
+	endpoint_reference ref;
+	ref.endpoint = endpoint;
+	ref.count = 0;
+	remote_endpoints.push_back(ref);
+}
+
+/// removes an endpoint from the list
+void BaseCommunication::remove_endpoint( const address_v* endpoint ) {
+	for (vector<endpoint_reference>::iterator i = remote_endpoints.begin();
+		i != remote_endpoints.end(); i++) {
+		if (*i->endpoint == *endpoint) {
+			i->count--;
+			if (i->count==0) {
+				logging_info("No more links to " << i->endpoint->to_string() << ": terminating transports!");
+				transport->terminate(i->endpoint);
+				remote_endpoints.erase(i);
+			}
+			return;
+		}
+	}
+}
+
 BaseCommunication::BaseCommunication() {
 	this->transport = NULL;
@@ -254,5 +284,5 @@
 }
 
-/// called when a message is received form transport_peer
+/// called when a message is received from transport_peer
 void BaseCommunication::receive_message(transport_protocol* transport,
 	const address_vf local, const address_vf remote, const uint8_t* data,
@@ -482,4 +512,5 @@
 /// add a newly allocated link to the set of links
 void BaseCommunication::addLink( LinkDescriptor* link ) {
+	add_endpoint(link->remoteLocator);
 	linkSet.push_back( link );
 }
@@ -489,4 +520,5 @@
 	for(LinkSet::iterator i=linkSet.begin(); i != linkSet.end(); i++){
 		if( (*i)->localLink != localLink) continue;
+		remove_endpoint((*i)->remoteLocator);
 		delete *i;
 		linkSet.erase( i );
Index: source/ariba/communication/BaseCommunication.h
===================================================================
--- source/ariba/communication/BaseCommunication.h	(revision 5508)
+++ source/ariba/communication/BaseCommunication.h	(revision 5614)
@@ -288,4 +288,17 @@
 	NetworkChangeDetection networkMonitor;
 #endif
+	/// list of all remote addresses of links to end-points
+	class endpoint_reference {
+	public:
+		int count; ///< the number of open links to this end-point
+		const address_v* endpoint; ///< the end-point itself
+	};
+	vector<endpoint_reference> remote_endpoints;
+
+	/// adds an end-point to the list
+	void add_endpoint( const address_v* endpoint );
+
+	/// removes an end-point from the list
+	void remove_endpoint( const address_v* endpoint );
 
 	/// event listener
@@ -306,4 +319,6 @@
 	void send( Message* message, const LinkDescriptor& descriptor );
 
+
+
 	/// state of the base communication
 	bool started;
