test/jdk/java/net/Socket/InheritTimeout.java
changeset 55645 3203e857fa71
parent 54811 9db7c0f561a6
equal deleted inserted replaced
55644:556313991cac 55645:3203e857fa71
     1 /*
     1 /*
     2  * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    54             }
    54             }
    55         }
    55         }
    56     }
    56     }
    57 
    57 
    58    InheritTimeout() throws Exception {
    58    InheritTimeout() throws Exception {
    59         ServerSocket ss = new ServerSocket(0);
    59         InetAddress ia = InetAddress.getLocalHost();
       
    60         ServerSocket ss = new ServerSocket();
       
    61         ss.bind(new InetSocketAddress(ia, 0));
    60         ss.setSoTimeout(1000);
    62         ss.setSoTimeout(1000);
    61 
    63 
    62         InetAddress ia = InetAddress.getLocalHost();
       
    63         InetSocketAddress isa =
    64         InetSocketAddress isa =
    64             new InetSocketAddress(ia, ss.getLocalPort());
    65             new InetSocketAddress(ia, ss.getLocalPort());
    65 
    66 
    66         // client establishes the connection
    67         // client establishes the connection
    67         Socket s1 = new Socket();
    68         Socket s1 = new Socket();