test/jdk/java/net/DatagramSocket/PortUnreachable.java
author pconcannon
Wed, 27 Nov 2019 16:01:34 +0000
changeset 59299 17d242844fc9
parent 58009 0daf32316b47
permissions -rw-r--r--
8233018: Add a new test to verify that DatagramSocket is not interruptible Summary: Test added to check the interruptability of DatagramSocket, MulticastSocket and DatagramSocketAdaptor. Reviewed-by: chegar, dfuchs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
54809
351da897f409 8223465: Replace wildcard address with loopback or local host in tests - part 3
aefimov
parents: 47243
diff changeset
     2
 * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 * @test
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * @bug 4361783
58009
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
    27
 * @key intermittent
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * @summary  Test to see if ICMP Port Unreachable on non-connected
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 *           DatagramSocket causes a SocketException "socket closed"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 *           exception on Windows 2000.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 */
47243
78fd493e38bb 8085875: java/net/DatagramSocket/PortUnreachable.java fails intermittently: Address already in use
xiaofeya
parents: 47216
diff changeset
    32
import java.net.BindException;
54809
351da897f409 8223465: Replace wildcard address with loopback or local host in tests - part 3
aefimov
parents: 47243
diff changeset
    33
import java.net.DatagramPacket;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.net.DatagramSocket;
54809
351da897f409 8223465: Replace wildcard address with loopback or local host in tests - part 3
aefimov
parents: 47243
diff changeset
    35
import java.net.InetAddress;
351da897f409 8223465: Replace wildcard address with loopback or local host in tests - part 3
aefimov
parents: 47243
diff changeset
    36
import java.net.InetSocketAddress;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
21947
2818a9404890 8025211: Intermittent test failure: java/net/DatagramSocket/PortUnreachable.java
msheppar
parents: 5506
diff changeset
    38
public class PortUnreachable {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    DatagramSocket clientSock;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    int serverPort;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    int clientPort;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
21947
2818a9404890 8025211: Intermittent test failure: java/net/DatagramSocket/PortUnreachable.java
msheppar
parents: 5506
diff changeset
    44
    public void serverSend() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
            InetAddress addr = InetAddress.getLocalHost();
58009
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
    47
            Thread.sleep(1000);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
            // send a delayed packet which should mean a delayed icmp
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
            // port unreachable
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
            byte b[] = "A late msg".getBytes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
            DatagramPacket packet = new DatagramPacket(b, b.length, addr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
                                                       serverPort);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
            clientSock.send(packet);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
47243
78fd493e38bb 8085875: java/net/DatagramSocket/PortUnreachable.java fails intermittently: Address already in use
xiaofeya
parents: 47216
diff changeset
    55
            DatagramSocket sock = recreateServerSocket(serverPort);
21947
2818a9404890 8025211: Intermittent test failure: java/net/DatagramSocket/PortUnreachable.java
msheppar
parents: 5506
diff changeset
    56
            b = "Greetings from the server".getBytes();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
            packet = new DatagramPacket(b, b.length, addr, clientPort);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
            sock.send(packet);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
            sock.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
            e.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
47243
78fd493e38bb 8085875: java/net/DatagramSocket/PortUnreachable.java fails intermittently: Address already in use
xiaofeya
parents: 47216
diff changeset
    65
    DatagramSocket recreateServerSocket (int serverPort) throws Exception {
78fd493e38bb 8085875: java/net/DatagramSocket/PortUnreachable.java fails intermittently: Address already in use
xiaofeya
parents: 47216
diff changeset
    66
        DatagramSocket serverSocket = null;
78fd493e38bb 8085875: java/net/DatagramSocket/PortUnreachable.java fails intermittently: Address already in use
xiaofeya
parents: 47216
diff changeset
    67
        int retryCount = 0;
58009
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
    68
        long sleeptime = 0;
47243
78fd493e38bb 8085875: java/net/DatagramSocket/PortUnreachable.java fails intermittently: Address already in use
xiaofeya
parents: 47216
diff changeset
    69
        System.out.println("Attempting to recreate server socket with port: " +
78fd493e38bb 8085875: java/net/DatagramSocket/PortUnreachable.java fails intermittently: Address already in use
xiaofeya
parents: 47216
diff changeset
    70
                serverPort);
58009
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
    71
        // it's possible that this method intermittently fails, if some other
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
    72
        // process running on the machine grabs the port we want before us,
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
    73
        // and doesn't release it before the 5 * 500 ms are elapsed...
47243
78fd493e38bb 8085875: java/net/DatagramSocket/PortUnreachable.java fails intermittently: Address already in use
xiaofeya
parents: 47216
diff changeset
    74
        while (serverSocket == null) {
78fd493e38bb 8085875: java/net/DatagramSocket/PortUnreachable.java fails intermittently: Address already in use
xiaofeya
parents: 47216
diff changeset
    75
            try {
54809
351da897f409 8223465: Replace wildcard address with loopback or local host in tests - part 3
aefimov
parents: 47243
diff changeset
    76
                serverSocket = new DatagramSocket(serverPort, InetAddress.getLocalHost());
47243
78fd493e38bb 8085875: java/net/DatagramSocket/PortUnreachable.java fails intermittently: Address already in use
xiaofeya
parents: 47216
diff changeset
    77
            } catch (BindException bEx) {
78fd493e38bb 8085875: java/net/DatagramSocket/PortUnreachable.java fails intermittently: Address already in use
xiaofeya
parents: 47216
diff changeset
    78
                if (retryCount++ < 5) {
58009
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
    79
                   sleeptime += sleepAtLeast(500);
47243
78fd493e38bb 8085875: java/net/DatagramSocket/PortUnreachable.java fails intermittently: Address already in use
xiaofeya
parents: 47216
diff changeset
    80
                } else {
58009
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
    81
                    System.out.println("Give up after 5 retries and " + sleeptime(sleeptime));
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
    82
                    System.out.println("Has some other process grabbed port " + serverPort + "?");
47243
78fd493e38bb 8085875: java/net/DatagramSocket/PortUnreachable.java fails intermittently: Address already in use
xiaofeya
parents: 47216
diff changeset
    83
                    throw bEx;
78fd493e38bb 8085875: java/net/DatagramSocket/PortUnreachable.java fails intermittently: Address already in use
xiaofeya
parents: 47216
diff changeset
    84
                }
78fd493e38bb 8085875: java/net/DatagramSocket/PortUnreachable.java fails intermittently: Address already in use
xiaofeya
parents: 47216
diff changeset
    85
            }
78fd493e38bb 8085875: java/net/DatagramSocket/PortUnreachable.java fails intermittently: Address already in use
xiaofeya
parents: 47216
diff changeset
    86
        }
78fd493e38bb 8085875: java/net/DatagramSocket/PortUnreachable.java fails intermittently: Address already in use
xiaofeya
parents: 47216
diff changeset
    87
78fd493e38bb 8085875: java/net/DatagramSocket/PortUnreachable.java fails intermittently: Address already in use
xiaofeya
parents: 47216
diff changeset
    88
        System.out.println("PortUnreachableTest.recreateServerSocket: returning socket == "
58009
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
    89
                + serverSocket.getLocalAddress() + ":" + serverSocket.getLocalPort()
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
    90
                + " obtained at " + attempt(retryCount) + " attempt with " + sleeptime(sleeptime));
47243
78fd493e38bb 8085875: java/net/DatagramSocket/PortUnreachable.java fails intermittently: Address already in use
xiaofeya
parents: 47216
diff changeset
    91
        return serverSocket;
78fd493e38bb 8085875: java/net/DatagramSocket/PortUnreachable.java fails intermittently: Address already in use
xiaofeya
parents: 47216
diff changeset
    92
    }
78fd493e38bb 8085875: java/net/DatagramSocket/PortUnreachable.java fails intermittently: Address already in use
xiaofeya
parents: 47216
diff changeset
    93
58009
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
    94
    long sleepAtLeast(long millis) throws Exception {
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
    95
        long start = System.nanoTime();
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
    96
        long ms = millis;
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
    97
        while (ms > 0) {
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
    98
            assert ms < Long.MAX_VALUE/1000_000L;
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
    99
            Thread.sleep(ms);
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
   100
            long elapsedms = (System.nanoTime() - start)/1000_000L;
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
   101
            ms = millis - elapsedms;
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
   102
        }
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
   103
        return millis - ms;
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
   104
    }
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
   105
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
   106
    String attempt(int retry) {
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
   107
        switch (retry) {
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
   108
            case 0: return "first";
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
   109
            case 1: return "second";
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
   110
            case 2: return "third";
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
   111
            default: return retry + "th";
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
   112
        }
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
   113
    }
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
   114
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
   115
    String sleeptime(long millis) {
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
   116
        if (millis == 0) return "no sleep";
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
   117
        long sec = millis / 1000L;
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
   118
        long ms =  millis % 1000L;
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
   119
        String sleeptime = "";
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
   120
        if (millis > 0) {
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
   121
           if (sec > 0) {
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
   122
               sleeptime = "" + sec + " s" +
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
   123
                   (ms > 0 ? " " : "");
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
   124
            }
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
   125
            if (ms > 0 ) {
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
   126
                sleeptime += ms + " ms";
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
   127
            }
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
   128
        } else sleeptime = millis + " ms"; // should not happen
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
   129
        return sleeptime + " of sleep time";
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
   130
    }
0daf32316b47 8230435: Replace wildcard address with loopback or local host in tests - part 22
dfuchs
parents: 54809
diff changeset
   131
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    PortUnreachable() throws Exception {
54809
351da897f409 8223465: Replace wildcard address with loopback or local host in tests - part 3
aefimov
parents: 47243
diff changeset
   133
        clientSock = new DatagramSocket(new InetSocketAddress(InetAddress.getLocalHost(), 0));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        clientPort = clientSock.getLocalPort();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
21947
2818a9404890 8025211: Intermittent test failure: java/net/DatagramSocket/PortUnreachable.java
msheppar
parents: 5506
diff changeset
   136
    }
2818a9404890 8025211: Intermittent test failure: java/net/DatagramSocket/PortUnreachable.java
msheppar
parents: 5506
diff changeset
   137
2818a9404890 8025211: Intermittent test failure: java/net/DatagramSocket/PortUnreachable.java
msheppar
parents: 5506
diff changeset
   138
    void execute () throws Exception{
2818a9404890 8025211: Intermittent test failure: java/net/DatagramSocket/PortUnreachable.java
msheppar
parents: 5506
diff changeset
   139
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        // pick a port for the server
54809
351da897f409 8223465: Replace wildcard address with loopback or local host in tests - part 3
aefimov
parents: 47243
diff changeset
   141
        DatagramSocket sock2 = new DatagramSocket(new InetSocketAddress(InetAddress.getLocalHost(), 0));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        serverPort = sock2.getLocalPort();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        // send a burst of packets to the unbound port - we should get back
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        // icmp port unreachable messages
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        InetAddress addr = InetAddress.getLocalHost();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        byte b[] = "Hello me".getBytes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        DatagramPacket packet = new DatagramPacket(b, b.length, addr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
                                                   serverPort);
21947
2818a9404890 8025211: Intermittent test failure: java/net/DatagramSocket/PortUnreachable.java
msheppar
parents: 5506
diff changeset
   151
        //close just before sending
2818a9404890 8025211: Intermittent test failure: java/net/DatagramSocket/PortUnreachable.java
msheppar
parents: 5506
diff changeset
   152
        sock2.close();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        for (int i=0; i<100; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            clientSock.send(packet);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
21947
2818a9404890 8025211: Intermittent test failure: java/net/DatagramSocket/PortUnreachable.java
msheppar
parents: 5506
diff changeset
   156
        serverSend();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        // try to receive
21947
2818a9404890 8025211: Intermittent test failure: java/net/DatagramSocket/PortUnreachable.java
msheppar
parents: 5506
diff changeset
   158
        b = new byte[25];
2818a9404890 8025211: Intermittent test failure: java/net/DatagramSocket/PortUnreachable.java
msheppar
parents: 5506
diff changeset
   159
        packet = new DatagramPacket(b, b.length, addr, serverPort);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        clientSock.setSoTimeout(10000);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        clientSock.receive(packet);
21947
2818a9404890 8025211: Intermittent test failure: java/net/DatagramSocket/PortUnreachable.java
msheppar
parents: 5506
diff changeset
   162
        System.out.println("client received data packet " + new String(packet.getData()));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        // done
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        clientSock.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    public static void main(String[] args) throws Exception {
21947
2818a9404890 8025211: Intermittent test failure: java/net/DatagramSocket/PortUnreachable.java
msheppar
parents: 5506
diff changeset
   169
        PortUnreachable test = new PortUnreachable();
2818a9404890 8025211: Intermittent test failure: java/net/DatagramSocket/PortUnreachable.java
msheppar
parents: 5506
diff changeset
   170
        test.execute();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
}