test/jdk/java/net/Socket/LinkLocal.java
changeset 55649 ad8e3b295615
parent 54811 9db7c0f561a6
equal deleted inserted replaced
55648:ba72dac556c3 55649:ad8e3b295615
     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.
    53 
    53 
    54         /*
    54         /*
    55          * Create ServerSocket on wildcard address and then
    55          * Create ServerSocket on wildcard address and then
    56          * try to connect Socket to link-local address.
    56          * try to connect Socket to link-local address.
    57          */
    57          */
    58         ServerSocket ss = new ServerSocket(0);
    58         ServerSocket ss = new ServerSocket();
       
    59         ss.bind(new InetSocketAddress(ia, 0));
    59 
    60 
    60         Socket s = new Socket();
    61         Socket s = new Socket();
    61         try {
    62         try {
    62             s.connect(new InetSocketAddress(ia, ss.getLocalPort()));
    63             s.connect(new InetSocketAddress(ia, ss.getLocalPort()));
    63 
    64 
    85         } else {
    86         } else {
    86             System.out.println("Test " + testCount + ": UDP send to " + ia);
    87             System.out.println("Test " + testCount + ": UDP send to " + ia);
    87         }
    88         }
    88 
    89 
    89         DatagramSocket ds1 = new DatagramSocket();
    90         DatagramSocket ds1 = new DatagramSocket();
    90         DatagramSocket ds2 = new DatagramSocket();
    91         DatagramSocket ds2 = new DatagramSocket(0, ia);
    91 
    92 
    92         try {
    93         try {
    93             byte b[] = "Hello".getBytes();
    94             byte b[] = "Hello".getBytes();
    94             DatagramPacket p = new DatagramPacket(b, b.length);
    95             DatagramPacket p = new DatagramPacket(b, b.length);
    95 
    96