Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6842359

(so) Socket adaptor getLocalPort method throws SocketException

XMLWordPrintable

    • b01
    • x86
    • windows_xp
    • Verified

      J2SE Version (please include all output from java -version flag):
      java version "1.6.0_13"
      Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
      Java HotSpot(TM) Client VM (build 11.3-b02, mixed mode, sharing)

      Does this problem occur on J2SE 5.0.x or 6.0? Yes / No (pick one)
      Yes

      Operating System Configuration Information (be specific):
      Client: Microsoft Windows XP [Version 5.1.2600]

      Bug Description:

      Error: java.net.SocketException: Socket operation on nonsocket: getsockname

      Calling channel.socket().getLocalPort() can result in an Error.
      The JavaDoc says: the local port number to which this socket is bound or -1 if the socket is not bound yet.
      No Error should ever be thrown by this method.

      java.lang.Error: java.net.SocketException: Socket operation on nonsocket: getsockname
      at sun.nio.ch.Net.localAddress(Net.java:125)
      at sun.nio.ch.SocketChannelImpl.localAddress(SocketChannelImpl.java:430)
      at sun.nio.ch.SocketAdaptor.getLocalPort(SocketAdaptor.java:159)

            igerasim Ivan Gerasimov
            tyao Ting-Yun Ingrid Yao (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: