|
1 | 1 | /* |
2 | | - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | 4 | * |
5 | 5 | * This code is free software; you can redistribute it and/or modify it |
|
28 | 28 | * |
29 | 29 | * @summary DatagramSocket.send should throw exception when connected |
30 | 30 | * to an invalid destination (on platforms that support it). |
31 | | - * @run main/othervm SendDatagramToBadAddress |
| 31 | + * @run main/othervm SendDatagramToBadAddress -d |
32 | 32 | */ |
33 | 33 |
|
34 | 34 | import java.net.*; |
@@ -70,6 +70,8 @@ public void receive (int loop, boolean expectError) throws Exception { |
70 | 70 | for (int i=0; i<loop; i++) { |
71 | 71 | try { |
72 | 72 | server.receive (pack); |
| 73 | + print("received data from address " + pack.getAddress() |
| 74 | + + " port " + pack.getPort()); |
73 | 75 | } catch (Exception e) { |
74 | 76 | if (expectError) { |
75 | 77 | print ("Got expected error: " + e); |
@@ -116,12 +118,15 @@ private void test(DatagramSocket sock) throws Exception { |
116 | 118 | DatagramPacket p; |
117 | 119 | byte[] buf; |
118 | 120 | int port = serversock.getLocalPort (); |
| 121 | + print("tests will be run against destination address " + addr + " port " + port); |
119 | 122 | final int loop = 5; |
120 | 123 | Server s = new Server (serversock); |
121 | 124 | int i; |
122 | 125 |
|
123 | 126 | print ("Checking send to connected address ..."); |
124 | 127 | sock.connect(addr, port); |
| 128 | + print("socket is locally bound to address " + sock.getLocalAddress() |
| 129 | + + " port " + sock.getLocalPort()); |
125 | 130 |
|
126 | 131 | for (i = 0; i < loop; i++) { |
127 | 132 | try { |
@@ -170,6 +175,8 @@ private void test(DatagramSocket sock) throws Exception { |
170 | 175 | sock.send(p); |
171 | 176 | p = new DatagramPacket(buf, buf.length, addr, port); |
172 | 177 | sock.receive (p); |
| 178 | + print("(unexpectedly) received data from address " + p.getAddress() |
| 179 | + + " port " + p.getPort() + " on attempt " + i); |
173 | 180 | } catch (InterruptedIOException ex) { |
174 | 181 | print ("socket timeout"); |
175 | 182 | } catch (Exception ex) { |
|
0 commit comments