Harmony
  1. Harmony
  2. HARMONY-6360

[classlib][luni]SocketTest and UnixSocketTest failed on AIX, because AIX do NOT support connect to port 0

    Details

    • Type: Test Test
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.0M12
    • Component/s: Classlib
    • Labels:
      None
    • Environment:
      AIX
    • Patch Info:
      Patch Available

      Description

      SocketTest failed on AIX at the statement "Socket s = new Socket("0.0.0.0", 0, false);" which create a socket in local and connect to IP address and port specified (0.0.0.0:0), which in turn actually connect to (machineIP:0) in PlainSocketImpl.java

      However AIX and some other Unix platform do NOT support connect to port 0.
      If you try to connect to your mahchine with port 0 in C program will get EADDRNOTAVAIL error on AIX and zos but it works well on Linux.

      1. 6360_v2.diff
        3 kB
        Ray Chen
      2. 6360.diff
        3 kB
        Ray Chen

        Activity

        Hide
        Ray Chen added a comment -

        In the patch, just use the port generated when new one ServerSocket above in SocketTest.java. And simply use a port number in UnixSocketTest.java.

        Show
        Ray Chen added a comment - In the patch, just use the port generated when new one ServerSocket above in SocketTest.java. And simply use a port number in UnixSocketTest.java.
        Hide
        Oliver Deakin added a comment -

        Hi Ray,
        Do you know if that UnixSocketTest works correctly on the RI on AIX? Can you successfully do "Socket socket = new Socket("127.0.0.1", 0, false);" on the RI on AIX, or does that also fail?

        Show
        Oliver Deakin added a comment - Hi Ray, Do you know if that UnixSocketTest works correctly on the RI on AIX? Can you successfully do "Socket socket = new Socket("127.0.0.1", 0, false);" on the RI on AIX, or does that also fail?
        Hide
        Ray Chen added a comment -

        Hi Oli,
        That also failed on both RI and harmony


        Regards,

        Ray Chen

        Show
        Ray Chen added a comment - Hi Oli, That also failed on both RI and harmony – Regards, Ray Chen
        Hide
        Oliver Deakin added a comment -

        Just one more thing on this - do you think the way the port is chosen in UnixSocketTest should be more like that in SocketTest. So instead of picking a fixed port number (which may be taken, and could cause intermittent failures because of this) we should make a getLocalPort() call and use that port number. Do you agree?

        Show
        Oliver Deakin added a comment - Just one more thing on this - do you think the way the port is chosen in UnixSocketTest should be more like that in SocketTest. So instead of picking a fixed port number (which may be taken, and could cause intermittent failures because of this) we should make a getLocalPort() call and use that port number. Do you agree?
        Hide
        Ray Chen added a comment -

        Hi Oli,

        Actually, I think the port is not important.

        When excute the original statement "Socket s = new Socket("0.0.0.0", 0,
        false);", there is no server at all. If port 0 used in socket() function,
        it means got a free port, and if port 0 used in connect() on Linux platform,
        it means connect to any listening port of the address (your local machine
        address here).

        However, AIX and many other Unix platform didn't support port 0 used in
        connect() function.

        Since you have questions about this, I think the code is a little bit
        confusing, maybe I should add some comments, right?


        Regards,

        Ray Chen

        Show
        Ray Chen added a comment - Hi Oli, Actually, I think the port is not important. When excute the original statement "Socket s = new Socket("0.0.0.0", 0, false);", there is no server at all. If port 0 used in socket() function, it means got a free port, and if port 0 used in connect() on Linux platform, it means connect to any listening port of the address (your local machine address here). However, AIX and many other Unix platform didn't support port 0 used in connect() function. Since you have questions about this, I think the code is a little bit confusing, maybe I should add some comments, right? – Regards, Ray Chen
        Hide
        Ray Chen added a comment -

        One more thing, these three test cases's purpose is to test the inputstream
        or outputstream of the socket, it doesn't care about if the connection is
        really connected. The question is AIX didn't allow to create a socket in
        this way(connect to port 0).

        Regards,

        Ray Chen

        Show
        Ray Chen added a comment - One more thing, these three test cases's purpose is to test the inputstream or outputstream of the socket, it doesn't care about if the connection is really connected. The question is AIX didn't allow to create a socket in this way(connect to port 0). – Regards, Ray Chen
        Hide
        Oliver Deakin added a comment -

        I understand that the 0 port usage does not work on AIX correctly - Im just wondering if UnixSocketTest will still work as expected if port 2934 is already in use?

        Show
        Oliver Deakin added a comment - I understand that the 0 port usage does not work on AIX correctly - Im just wondering if UnixSocketTest will still work as expected if port 2934 is already in use?
        Hide
        Ray Chen added a comment -

        Hi Oli,

        That's a good question. I will have a try, maybe still give it a free port
        and add more comments.


        Regards,

        Ray Chen

        Show
        Ray Chen added a comment - Hi Oli, That's a good question. I will have a try, maybe still give it a free port and add more comments. – Regards, Ray Chen
        Hide
        Ray Chen added a comment -

        Latest patch gets a free port in UnixTest, and add some comments in both testcases.

        Show
        Ray Chen added a comment - Latest patch gets a free port in UnixTest, and add some comments in both testcases.
        Hide
        Oliver Deakin added a comment -

        Hi Ray - thanks for the new patch. That looks better, but one thing still puzzles me. How can the ServerSocket get a free port when it is passed 0 but Socket cannot?

        Show
        Oliver Deakin added a comment - Hi Ray - thanks for the new patch. That looks better, but one thing still puzzles me. How can the ServerSocket get a free port when it is passed 0 but Socket cannot?
        Hide
        Ray Chen added a comment -

        AIX allow socket(port0), but do not allow connect(port0).

        That's why we can create a server socket with port0, but we can not make a
        client to a port0


        Regards,

        Ray Chen

        Show
        Ray Chen added a comment - AIX allow socket(port0), but do not allow connect(port0). That's why we can create a server socket with port0, but we can not make a client to a port0 – Regards, Ray Chen
        Hide
        Ray Chen added a comment -

        Hi Oli,

        This is the description copied from the Spec for the socket
        construction -"Creates
        a socket and connects it to the specified port number at the specified IP
        address"

        So here, it is server's IP and port, not local. In C it might be like
        socket();
        connect(ip, port ,len)

        But in ServerSocket(0), it is also server's, but it is local port.
        In C it might be like socket(family,port,...)

        So this two sockets' role are different.


        Regards,

        Ray Chen

        Show
        Ray Chen added a comment - Hi Oli, This is the description copied from the Spec for the socket construction -"Creates a socket and connects it to the specified port number at the specified IP address" So here, it is server's IP and port, not local. In C it might be like socket(); connect(ip, port ,len) But in ServerSocket(0), it is also server's, but it is local port. In C it might be like socket(family,port,...) So this two sockets' role are different. – Regards, Ray Chen
        Hide
        Oliver Deakin added a comment -

        Thanks Ray - I get it now Patch applied at repo revision r828837. Please check it applied as expected and close this JIRA.

        Show
        Oliver Deakin added a comment - Thanks Ray - I get it now Patch applied at repo revision r828837. Please check it applied as expected and close this JIRA.
        Hide
        Hudson added a comment -

        Integrated in Harmony-1.5-head-linux-x86_64 #511 (See http://hudson.zones.apache.org/hudson/job/Harmony-1.5-head-linux-x86_64/511/)
        Apply patch for ([classlib][luni]SocketTest and UnixSocketTest failed on AIX, because AIX do NOT support connect to port 0)

        Show
        Hudson added a comment - Integrated in Harmony-1.5-head-linux-x86_64 #511 (See http://hudson.zones.apache.org/hudson/job/Harmony-1.5-head-linux-x86_64/511/ ) Apply patch for ( [classlib] [luni] SocketTest and UnixSocketTest failed on AIX, because AIX do NOT support connect to port 0)
        Hide
        Ray Chen added a comment -

        Patch verified.

        Thank you, Oli, your comments make this patch better.

        Show
        Ray Chen added a comment - Patch verified. Thank you, Oli, your comments make this patch better.

          People

          • Assignee:
            Oliver Deakin
            Reporter:
            Ray Chen
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 0.5h
              0.5h
              Remaining:
              Remaining Estimate - 0.5h
              0.5h
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development