Index: source/ariba/communication/BaseCommunication.cpp
===================================================================
--- source/ariba/communication/BaseCommunication.cpp	(revision 2467)
+++ source/ariba/communication/BaseCommunication.cpp	(revision 2483)
@@ -85,5 +85,5 @@
 
 	for( ; i != iend; i++){
-		logging_debug( "local locator found " + (*i)->toString() );
+		logging_debug( "local locator found " << (*i)->toString() );
 		IPv4Locator* ipv4locator = dynamic_cast<IPv4Locator*>(*i);
 
@@ -101,5 +101,5 @@
 			localDescriptor.locator = ipv4locator;
 			localDescriptor.isUnspec = false;
-			logging_info( "binding to addr = " + ipv4locator->toString() );
+			logging_info( "binding to addr = " << ipv4locator->toString() );
 			foundLocator = true;
 			break;
@@ -180,6 +180,6 @@
 	LinkID linkid = LinkID::create();
 
-	logging_debug( "creating new local descriptor entry with local link id " + linkid.toString() );
-	LinkDescriptor linkDescriptor( linkid, local, LinkID::UNSPECIFIED, remote, descriptor );
+	logging_debug( "creating new local descriptor entry with local link id " << linkid.toString() );
+	LinkDescriptor linkDescriptor( linkid, local, LinkID::UNSPECIFIED, remote, descriptor, false );
 	addLink( linkDescriptor );
 
@@ -189,5 +189,5 @@
 	//
 
-	logging_debug( "sending out base messages with request to open link to " + remote->toString() );
+	logging_debug( "sending out base messages with request to open link to " << remote->toString() );
 	AribaBaseMsg baseMsg( remote, AribaBaseMsg::LINK_STATE_OPEN_REQUEST, linkid,
 								LinkID::UNSPECIFIED );
@@ -206,4 +206,10 @@
 		logging_error( "don't know the link you want to drop" );
 		return;
+	}
+
+	// warn if this link has some queued messages attached
+	if( descriptor.waitingmsg.size() > 0 ){
+		logging_warn( "dropping link " << link.toString() << 
+			" that has " << descriptor.waitingmsg.size() << " waiting messages" );
 	}
 
@@ -231,11 +237,11 @@
 seqnum_t BaseCommunication::sendMessage( const LinkID lid, const Message* message) {
 
-	logging_debug( "sending out message to link " + lid.toString() );
+	logging_debug( "sending out message to link " << lid.toString() );
 
 	// query local link info
 	LinkDescriptor& linkDesc = queryLocalLink(lid);
 	if( linkDesc.isUnspecified() ){
-		logging_error( "don't know the link with id " + lid.toString() );
-		return 0;
+		logging_error( "don't know the link with id " << lid.toString() );
+		return -1;
 	}
 
@@ -251,8 +257,19 @@
 	msg.encapsulate( const_cast<Message*>(message) );
 
-	// send message
-	transport->sendMessage( &msg );
-
-	return ++currentSeqnum;
+	if( linkDesc.linkup ){
+
+		// send message
+		transport->sendMessage( &msg );
+		return ++currentSeqnum;
+
+	} else {
+
+		// queue message
+		logging_info( "link " << lid.toString() << " is not up yet, queueing message" );
+		linkDesc.waitingmsg.push_back( new Message(msg) ); // TODO ooooo
+
+		return 0;
+
+	} // if( linkDesc.linkup )
 }
 
@@ -300,5 +317,5 @@
 
 	AribaBaseMsg* spovmsg = ((Message*)message)->decapsulate<AribaBaseMsg>();
-	logging_debug( "receiving base comm message of type " + spovmsg->getTypeString() );
+	logging_debug( "receiving base comm message of type " << spovmsg->getTypeString() );
 
 	//
@@ -351,5 +368,6 @@
 		const NetworkLocator* remoteLocator = dynamic_cast<const NetworkLocator*>(message->getSourceAddress());
 
-		logging_debug( "localLocator=" + localLocator->toString() + " remoteLocator="+remoteLocator->toString());
+		logging_debug( "localLocator=" << localLocator->toString() 
+				<< " remoteLocator=" << remoteLocator->toString());
 
 		// ask the registered listeners if this link
@@ -372,5 +390,5 @@
 
 		LinkDescriptor linkDescriptor(localLink, localLocator, remoteLink,
-					remoteLocator, EndpointDescriptor(remoteLocator));
+					remoteLocator, EndpointDescriptor(remoteLocator), true);
 
 		logging_debug( "saving new link descriptor with " <<
@@ -378,5 +396,6 @@
 				"[local locator " << localLocator->toString() << "] " <<
 				"[remote link " << remoteLink.toString() << "] " <<
-				"[remote locator " << remoteLocator->toString() << "]" );
+				"[remote locator " << remoteLocator->toString() << "]" <<
+				"[link up true]" );
 
 		addLink( linkDescriptor );
@@ -400,5 +419,5 @@
 		// the link is now open
 		//
-
+		
 		BOOST_FOREACH( CommunicationEvents* i, eventListener ){
 			i->onLinkUp( localLink, localLocator, remoteLocator );
@@ -420,10 +439,12 @@
 
 		if (linkDesc.isUnspecified()) {
-			logging_warn("Failed to find local link "+spovmsg->getRemoteLink().toString());
+			logging_warn("Failed to find local link " << spovmsg->getRemoteLink().toString());
 			return false;
 		}
 
 		linkDesc.remoteLink = spovmsg->getLocalLink();
-		logging_debug( "the link is now up with local link id " + spovmsg->getRemoteLink().toString() );
+		linkDesc.linkup = true;	
+	
+		logging_debug( "the link is now up with local link id " << spovmsg->getRemoteLink().toString() );
 
 		BOOST_FOREACH( CommunicationEvents* i, eventListener ){
@@ -431,4 +452,15 @@
 		}
 
+		if( linkDesc.waitingmsg.size() > 0 ){ 
+			logging_info( "sending out queued messages on link " << linkDesc.localLink.toString() );
+
+			BOOST_FOREACH( Message* msg, linkDesc.waitingmsg ){
+				sendMessage( linkDesc.localLink, msg );
+				delete msg;
+			}
+
+			linkDesc.waitingmsg.clear();
+		}
+
 	} // LINK_STATE_OPEN_REPLY
 
@@ -440,5 +472,5 @@
 
 		const LinkID& localLink = spovmsg->getRemoteLink();
-		logging_debug( "received link close request for link " + localLink.toString() );
+		logging_debug( "received link close request for link " << localLink.toString() );
 
 		//
@@ -450,5 +482,5 @@
 		LinkDescriptor& linkDesc = queryLocalLink( localLink );
 		if (linkDesc.isUnspecified()) {
-			logging_warn("Failed to find local link "+localLink.toString());
+			logging_warn("Failed to find local link " << localLink.toString());
 			return false;
 		}
@@ -469,5 +501,5 @@
 
 		const LinkID& localLink = spovmsg->getRemoteLink();
-		logging_debug( "received link update for link " + localLink.toString() );
+		logging_debug( "received link update for link " << localLink.toString() );
 
 		//
@@ -477,5 +509,5 @@
 		LinkDescriptor& linkDesc = queryLocalLink( localLink );
 		if (linkDesc.isUnspecified()) {
-			logging_warn("Failed to update local link "+localLink.toString());
+			logging_warn("Failed to update local link " << localLink.toString());
 			return false;
 		}
@@ -517,8 +549,14 @@
 
 	for( ; i != iend; i++){
-		if( (*i).localLink == localLink){
-			linkSet.erase( i );
-			break;
-		}
+		if( (*i).localLink != localLink) continue;
+		
+		BOOST_FOREACH( Message* msg, i->waitingmsg ){
+			delete msg;
+		}
+
+		i->waitingmsg.clear();
+		linkSet.erase( i );
+
+		break;
 	}
 }
@@ -568,5 +606,5 @@
 		info.type != NetworkChangeInterface::EventTypeAddressDelete ) return;
 
-	logging_info("base communication is handling network address changes");
+	logging_info( "base communication is handling network address changes" );
 
 	//
@@ -610,5 +648,5 @@
 
 	for( ; i != iend; i++){
-		logging_debug( "local locator found " + (*i)->toString() );
+		logging_debug( "local locator found " << (*i)->toString() );
 		IPv4Locator* ipv4locator = dynamic_cast<IPv4Locator*>(*i);
 
Index: source/ariba/communication/BaseCommunication.h
===================================================================
--- source/ariba/communication/BaseCommunication.h	(revision 2467)
+++ source/ariba/communication/BaseCommunication.h	(revision 2483)
@@ -46,4 +46,5 @@
 #include <vector>
 #include <iostream>
+#include <deque>
 #include <algorithm>
 #include <boost/foreach.hpp>
@@ -77,4 +78,5 @@
 using std::map;
 using std::vector;
+using std::deque;
 using std::pair;
 using std::make_pair;
@@ -222,15 +224,17 @@
 			remoteLink(),
 			remoteLocator(NULL),
-			remoteEndpoint(EndpointDescriptor::UNSPECIFIED){
+			remoteEndpoint(EndpointDescriptor::UNSPECIFIED),
+			linkup(false) {
 		}
 
 		LinkDescriptor(const LinkID& _localLink, const NetworkLocator*& _localLocator,
 				const LinkID& _remoteLink, const NetworkLocator*& _remoteLocator,
-				const EndpointDescriptor& _remoteEndpoint ) :
+				const EndpointDescriptor& _remoteEndpoint, bool _linkup ) :
 			localLink(_localLink),
 			localLocator(_localLocator),
 			remoteLink(_remoteLink),
 			remoteLocator(_remoteLocator),
-			remoteEndpoint(_remoteEndpoint){
+			remoteEndpoint(_remoteEndpoint),
+			linkup(_linkup) {
 		}
 
@@ -240,5 +244,10 @@
 			remoteLink(desc.remoteLink),
 			remoteLocator(desc.remoteLocator),
-			remoteEndpoint(desc.remoteEndpoint){
+			remoteEndpoint(desc.remoteEndpoint),
+			linkup(desc.linkup) {
+
+			BOOST_FOREACH( Message* msg, desc.waitingmsg ){
+				waitingmsg.push_back( msg );
+			}
 		}
 
@@ -252,4 +261,7 @@
 		const NetworkLocator* 	remoteLocator;
 		EndpointDescriptor 	remoteEndpoint;
+
+		bool 			linkup;
+		deque<Message*>		waitingmsg;
 	};
 
