Пример #1
0
		/// <summary>
		/// Create a new Debugger object, configured to listen for connections
		/// on a specific port.
		/// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: Debugger(Client client, int listenPort) throws java.io.IOException
		internal Debugger(Client client, int listenPort)
		{

			mClient = client;
			mListenPort = listenPort;

			mListenChannel = ServerSocketChannel.open();
			mListenChannel.configureBlocking(false); // required for Selector

			var addr = new DnsEndPoint("localhost", listenPort); //$NON-NLS-1$
			mListenChannel.socket().ExclusiveAddressUse = false; // .reuseAddress = true; // enable SO_REUSEADDR
			mListenChannel.socket().Bind(addr);

			mReadBuffer = ByteBuffer.allocate(INITIAL_BUF_SIZE);
			mPreDataBuffer = ByteBuffer.allocate(PRE_DATA_BUF_SIZE);
			mConnState = ST_NOT_CONNECTED;

			Log.d("ddms", "Created: " + this.ToString());
		}
Пример #2
0
        /// <summary>
        /// Opens (or reopens) the "debug selected" port and listen for connections. </summary>
        /// <returns> true if the port was opened successfully. </returns>
        /// <exception cref="IOException"> </exception>
        private bool reopenDebugSelectedPort()
        {
            Log.d("ddms", "reopen debug-selected port: " + mNewDebugSelectedPort);
            if (mDebugSelectedChan != null)
            {
                mDebugSelectedChan.close();
            }

            mDebugSelectedChan = ServerSocketChannel.open();
            mDebugSelectedChan.configureBlocking(false); // required for Selector

            var addr = new DnsEndPoint("localhost", mNewDebugSelectedPort); //$NON-NLS-1$
            mDebugSelectedChan.socket().ExclusiveAddressUse = false; // enable SO_REUSEADDR

            try
            {
                mDebugSelectedChan.socket().Bind(addr);
                if (mSelectedClient != null)
                {
                    mSelectedClient.update(Client.CHANGE_PORT);
                }

                mDebugSelectedChan.register(mSelector, SelectionKey.OP_ACCEPT, this);

                return true;
            }
            catch (Exception)
            {
                displayDebugSelectedBindError(mNewDebugSelectedPort);

                // do not attempt to reopen it.
                mDebugSelectedChan = null;
                mNewDebugSelectedPort = -1;

                return false;
            }
        }