Esempio n. 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGivePortConflictErrorWithPortNumberInIt() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldGivePortConflictErrorWithPortNumberInIt()
        {
            // Given an occupied port
            int port = 16000;

            using (ServerSocketChannel ignore = ServerSocketChannel.open().bind(new InetSocketAddress("localhost", port)))
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.helpers.ListenSocketAddress address = new org.neo4j.helpers.ListenSocketAddress("localhost", port);
                ListenSocketAddress address = new ListenSocketAddress("localhost", port);

                // Expect
                Exception.expect(typeof(PortBindException));

                // When
                IDictionary <BoltConnector, NettyServer.ProtocolInitializer> initializersMap = genericMap(new BoltConnector("test"), ProtocolOnAddress(address));
                (new NettyServer(new NamedThreadFactory("mythreads"), initializersMap, new ConnectorPortRegister(), NullLog.Instance)).start();
            }
        }
Esempio n. 2
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());
        }
Esempio n. 3
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);
            }
        }