Uploaded image for project: 'MINA'
  1. MINA
  2. DIRMINA-266

SocketAcceptor.bind() requires address != null and port != 0... why? Also can get to ServerSocketChannel.socket().getLocalSocketAddress()

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.9.5
    • 1.0.1
    • None
    • None

    Description

      public void bind( SocketAddress address, IoHandler handler, IoServiceConfig config ) throws IOException
      {
      // if( address == null )
      //

      { // throw new NullPointerException( "address" ); // }

      if( handler == null )

      { throw new NullPointerException( "handler" ); }

      if( address != null && !( address instanceof InetSocketAddress ) )

      { throw new IllegalArgumentException( "Unexpected address type: " + address.getClass() ); }

      // if( ( ( InetSocketAddress ) address ).getPort() == 0 )
      //

      { // throw new IllegalArgumentException( "Unsupported port number: 0" ); // }

      ...

      Also, you need to fix the physical binding and registration in the channels map:

      // and bind.
      ssc.socket().bind( req.address, cfg.getBacklog() );

      // assign what was actually bound
      //
      req.address = ssc.socket().getLocalSocketAddress();

      ssc.register( selector, SelectionKey.OP_ACCEPT, req );

      I am by no means a networking genius, but is there a reason why this type of use is not allowed?

      Also, if assigning the SocketAddress at bind is used, there needs to be a way for you to get the local socket address from the IoSession api.

      Thanks,
      Michael

      Attachments

        Activity

          People

            trustin Trustin Lee
            michael.newcomb Michael Newcomb
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: