Esempio n. 1
0
		public SocketConnector( string IP, int Port ) {
			mIP = IP;
			mPort = Port;
			IPHostEntry iphe = null;
			try {
				iphe = Dns.GetHostEntry( mIP );
				if( iphe == null || iphe.AddressList.Length < 1 )
					throw new Exception( "Unable to fetch IP Address from: " + mIP + "::" + mPort );
			} catch( Exception e ) {
				throw e;
			}

			IPEndPoint EndPoint = new IPEndPoint( iphe.AddressList[ 0 ], mPort );

			bool bSuccess = false;
			do {
				SocketListener Listener = new SocketListener( EndPoint, this );
				if( bSuccess == false && Listener != null )
					bSuccess = true;
				mListener = Listener;

				if( bSuccess == false ) {
					CConsole.ErrorLine( "Unable to Connect - retrying in 10sec..." );
					Thread.Sleep( 10000 );
				}
			} while( bSuccess == false );

			mQueue = new Queue<NetState>();
			mWorkingQueue = new Queue<NetState>();
			mThrottled = new Queue<NetState>();
			mPeek = new byte[ 4 ];
		}