Example #1
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);
            }
        }
Example #2
0
        /// <summary>
        /// Register the debugger's listen socket with the Selector.
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: void registerListener(java.nio.channels.Selector sel) throws java.io.IOException
        internal virtual void registerListener(Selector sel)
        {
            mListenChannel.register(sel, SelectionKey.OP_ACCEPT, this);
        }