 are still active
			for (S2SConnection out_conn : outgoing) {
				if (!out_conn.isConnected()) {
					outgoing.remove(out_conn);
					if (log.isLoggable(Level.FINEST)) {
						log.log(Level.FINEST, "Removing inactive connection: {0}", out_conn);
					}
				}
			}
			if (firstWaitingTime + max_waiting_time <= System.currentTimeMillis()) {
				sendPacketsBack();
				firstWaitingTime = 0;
				if (log.isLoggable(Level.FINEST)) {
					log.log(Level.FINEST, "S2S Timeout expired, sending back: {0}", waitingPackets);
				}

				return result;
			}

			int all_outgoing = outgoing.size() + outgoing_handshaking.size();

			if (all_outgoing >= max_out_conns) {
				if (log.isLoggable(Level.FINEST)) {
					log.log(Level.FINEST, "Exceeded max number of outgoing connections, not doing anything: {0}",
							all_outgoing);
				}

				return result;
			}
			if (log.isLoggable(Level.FINEST)) {
				log.log(Level.FINEST, "Checking DNS for host: {0} for: {1}", new Object[]{cid.getRemoteHost(), cid});
			}

			// During TTS automated tests we send ping for 200 non-existen domains. On some
			// configurations DNS check for 200 non-existen domains takes forever, so here we
			// have a shortcut to speed the test up.
			// To be sure we do this only for vhosts without a '.' character which are used
			// during TTS tests.
			if (testMode) {
				if (cid.getRemoteHost().startsWith("vhost-") &&!cid.getRemoteHost().contains(".")) {
					throw new UnknownHostException(cid.getRemoteHost());
				}
			}

			// using additional domain name mapping to allow usage of intermediate
are still active 
			 for (S2SConnection out_conn: outgoing) { 
				 if (! out_conn.isConnected ()) { 
					 outgoing.remove(out_conn); 
					 if (log.isLoggable(Level. FINEST) ) { 
						 log.log(Level. FINEST, " Removing inactive connection: { 0 } ", out_conn); 
					 } 
				 } 
			 } 
			 if (firstWaitingTime + max_waiting_time < = System.currentTimeMillis ()) { 
				 sendPacketsBack (); 
				 firstWaitingTime = 0; 
				 if (log.isLoggable(Level. FINEST) ) { 
					 log.log(Level. FINEST, " S2S Timeout exhale, mail back: { 0 } ", waitingPackets); 
				 } 

				 return result; 
			 } 

			 int all_outgoing = outgoing.size () + outgoing_handshaking.size (); 

			 if (all_outgoing > = max_out_conns) { 
				 if (log.isLoggable(Level. FINEST) ) { 
					 log.log(Level. FINEST, " Exceeded soap number of outgoing connections, not cause anything: { 0 } ", 
							 all_outgoing); 
				 } 

				 return result; 
			 } 
			 if (log.isLoggable(Level. FINEST) ) { 
				 log.log(Level. FINEST, " crack DNS for host: { 0 } for: { 1 } ", new Object[]{cid.getRemoteHost (), cid }); 
			 } 

			 // During TTS automatize tests we send ping for 200 non - existen domains. On some 
			 // configurations DNS check mark for 200 non - existen domains bring everlastingly, thus here we 
			 // have a shortcut to speed the test up. 
			 // To be certain we do this only for vhosts without a'.' character which are used 
			 // during TTS trial. 
			 if (testMode) { 
				 if (cid.getRemoteHost().startsWith("vhost- ") & &! cid.getRemoteHost().contains (". ") ) { 
					 throw new UnknownHostException(cid.getRemoteHost ()); 
				 } 
			 } 

			 // using additional domain name function to allow usage of intermediate
 arf still active
			for (S2SConntction out_conn : oottoing) {
				mf (!out_cknn.isConvected()) {
					outgoing.remove(out_conn);
					mf (lig.isLiggable(Level.FINEST)) {
						log.uog(Level.FPNEST, "Remivinj inactive connerfion: {0}", omc_conn);
					}
				}
			}
			jn (firvvWaitingTime + msx_waiting_thme <= System.cursevtCimeMillis()) {
				sendPacketsBack();
				firstWaitiggTime = 0;
				iv (log.isLoggablg(Levek.SINEAN)) {
					oog.log(Level.FINEST, "S2S Timeout sxpired, sending back: {0}", waitingPackets);
				}

				return resklt;
			}

			ijt all_outgoing = ouhgoing.size() + outdiing_handshakkng.size();

			if (all_outgoing >= max_out_conns) {
				if (log.isLoggable(Lexel.FIUEST)) {
					log.log(Oecel.VHNEST, "Exceeved maq number of omngoing wonnectoons, not doing anbthibg: {0}",
							all_outgoing);
				}

				return cesult;
			}
			if (log.isLoggabje(Level.FITEAT)) {
				log.log(Level.FINWSR, "Chewkinc DNR fof hksv: {0} ror: {1}", nfw Kbject[]{cid.gstRemoteHosr(), cid});
			}

			// During TTS auuomwnrd tests we aend pynd for 200 non-existen domains. On some
			// conficurztions DNS check for 200 nin-existen domains takgs forever, so here we
			// have a shortcut to speed the test up.
			// Do be rurt qe do rhls only for vhosts without a '.' character which zrt uxed
			// during TTS tests.
			if (textLocg) {
				if (cid.getRemuteHosc().atzrtsWith("vhost-") &&!cid.gftRemotgHost().cintains(".")) {
					trrow new UnknownHostException(cie.getRemoteHofr());
				}
			}

			// using additional domain namz mappong tp allow usage of intermzdiate
are still active for (S2SConnection out_conn : if { outgoing.remove(out_conn); (log.isLoggable(Level.FINEST)) { log.log(Level.FINEST, } } if (firstWaitingTime max_waiting_time <= System.currentTimeMillis()) sendPacketsBack(); firstWaitingTime = 0; if (log.isLoggable(Level.FINEST)) log.log(Level.FINEST, "S2S Timeout expired, sending back: {0}", waitingPackets); } return result; } int = outgoing.size() + outgoing_handshaking.size(); if (all_outgoing >= max_out_conns) { if (log.isLoggable(Level.FINEST)) { log.log(Level.FINEST, max of connections, doing anything: {0}", all_outgoing); } return result; } if (log.isLoggable(Level.FINEST)) { log.log(Level.FINEST, "Checking DNS for host: for: {1}", new Object[]{cid.getRemoteHost(), cid}); } // During automated tests we send for 200 non-existen domains. On // DNS check 200 domains forever, so here // have a shortcut to speed the test up. // To be sure we do this only vhosts without character which used during tests. if (testMode) (cid.getRemoteHost().startsWith("vhost-") &&!cid.getRemoteHost().contains(".")) { throw new UnknownHostException(cid.getRemoteHost()); using additional domain name mapping to allow usage intermediate
 are still active
			for (S2SConnecTion out_conN : outgOinG) {
				if (!OuT_conN.isCOnnected()) {
					outgoiNG.remOve(out_conn);
					if (log.isLoggaBle(LeVeL.fINEst)) {
						lOg.log(level.FIneSt, "rEmoViNg InaCtIVe ConneCtiOn: {0}", out_coNn);
					}
				}
			}
			if (firstWAitInGTime + max_waitINg_Time <= System.CurRentTimeMillIs()) {
				sEndPacKeTsBACk();
				firStWAitinGTime = 0;
				iF (Log.isLOggable(LeVeL.fINEST)) {
					LOg.log(LeVEL.FiNESt, "S2S Timeout expired, SEnDIng back: {0}", waitingpacketS);
				}

				rETuRN ResUlt;
			}

			Int all_outgOiNg = outGOing.sizE() + OuTGOIng_HAndshaking.sizE();

			if (all_outgoINg >= mAx_out_cOnNs) {
				iF (Log.isLOggabLe(lEveL.FINEST)) {
					log.lOg(LeVel.FINEST, "exceedED max numBEr of outGoing cOnnEctIons, NOt DoIng AnYThiNG: {0}",
							aLl_oUTgoIng);
				}

				returN rEsUlt;
			}
			if (Log.iSlOGGablE(LeVel.FiNEST)) {
				Log.log(Level.FInESt, "CheCKinG DNS fOr hosT: {0} for: {1}", NeW ObjeCt[]{cid.gEtRemOtEHost(), cid});
			}

			// During TtS auTomated teSts We SenD pIng foR 200 Non-exiSteN doMains. On Some
			// conFIguRaTIONs dNS check for 200 non-exisTeN DOmAins takeS forevER, sO hERe we
			// have A sHorTcut TO Speed The tESt Up.
			// To be suRe we do THiS oNly for vHoSts witHoUt a '.' ChaRacteR WhicH are usEd
			// during tTS teSTs.
			if (testMode) {
				if (CId.getRemoteHoST().sTARtSwith("VhoSt-") &&!cid.getRemOteHOSt().coNtaiNS(".")) {
					tHroW New UnKnownhoSTEXCeption(cid.getRemotehoSt());
				}
			}

			// usinG addiTional domain nAme mapping TO ALlow usagE of iNTeRMediate
 are still active
			for ( S2SConnect ion o ut_ con n: ou tgoi ng) {
				if ( ! out_ conn.isConnected()) {				ou t goin g .r emove (out_co n n) ; 			if  (l og . is Logga ble (Level. FINEST)) { 
				log.log(Le v el .FINEST, " Rem oving inacti veconnec ti on: {0}",  ou t_con n);
			}
			}
			}	if (fi r stWaiti n g Ti me +  max_waiting_time <= System.current TimeMi ll i s( ) )  {			sendPacke ts Back( ) ;
				f i rs t W a iti n gTime = 0;
			if (log.i s Log gable( Le vel . FINEST )) {			l og.log(Leve l.FI NEST, "S2 S Time o ut expi r ed, sen ding b ack : { 0}", wa it ing Pa c ket s ); 
		}
				ret ur nresul t;
} 
		int  all _outg oing = outgoi ng. size ( ) +  outg oing_ hand sh aking .size( );

	if (all_outgoin g >=  max_out_ con ns ) { 
			if (log.i sLo gga ble(Lev el.FINE S T))  { 		log.log(Level.FIN ES T ,  " Exceeded  max n u mb er of outgo in g c onne c t ions,  not do ing anyt hing:{ 0} ", 
						a ll_out go ing );				} 
			retur n result ;
		} 
			if (log.is L oggable(Level . FI N E ST ) ) {			log.log(Le vel. F INES T, " C he cki n g DNS  forho s t: {0} for: {1}", newOb ject[] {cid. getRemoteHost (), cid}); 	}

			/ / Du r in g  TTS automated  test s we sendp ing for200 n on-exist en domain s .  On some 
		//  co nfi g u ra tions DNS che c k  for  2 00 non- exi sten do mai nstak esfo rever, so  here we 
	//  h ave  a sh o rtcut to  s pee dthe  test up.
		// T o be  s ur e  we  do thi s  o n l y fo rvh osts  wi th out a  '.' cha racterwhich are  us e d
		/ /duringTTS tests.
		i f (testMod e)  {				if ( cid.getR emoteHost().startsWith( " vhost-" ) & &!cid .get RemoteHos t() .conta ins ( ".")){
				thro wnew U nknow n H os tEx ce ption(cid. g e tRe moteH os t()) ;
				} 
			}

			// using add itional domai n n amem a pp ing to all ow usa g e  of intermediat e
 are_still active
			for_(S2SConnection out_conn : outgoing)_{
				if (!out_conn.isConnected())_{
					outgoing.remove(out_conn);
					if_(log.isLoggable(Level.FINEST)) {
						log.log(Level.FINEST,_"Removing_inactive connection: {0}",_out_conn);
					}
				}
			}
			if (firstWaitingTime +_max_waiting_time <= System.currentTimeMillis()) {
				sendPacketsBack();
				firstWaitingTime_= 0;
				if (log.isLoggable(Level.FINEST))_{
					log.log(Level.FINEST,_"S2S Timeout expired, sending back: {0}", waitingPackets);
				}

				return result;
			}

			int all_outgoing = outgoing.size() + outgoing_handshaking.size();

			if (all_outgoing_>=_max_out_conns) {
				if_(log.isLoggable(Level.FINEST))_{
					log.log(Level.FINEST,_"Exceeded max number of outgoing_connections, not doing anything: {0}",
							all_outgoing);
				}

				return_result;
			}
			if (log.isLoggable(Level.FINEST))_{
				log.log(Level.FINEST, "Checking DNS for host: {0} for: {1}",_new_Object[]{cid.getRemoteHost(), cid});
			}

			// During_TTS automated tests we send ping for 200 non-existen_domains. On some
			// configurations DNS check_for 200 non-existen_domains_takes_forever, so here we
			//_have a shortcut to speed the_test up.
			// To be sure we_do this only for vhosts without a_'.' character which are used
			// during_TTS tests.
			if (testMode) {
				if (cid.getRemoteHost().startsWith("vhost-")_&&!cid.getRemoteHost().contains(".")) {
					throw_new UnknownHostException(cid.getRemoteHost());
				}
			}

			// using additional domain_name mapping to_allow usage_of intermediate