equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2000, 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. |
112 public void run() throws Exception { |
112 public void run() throws Exception { |
113 |
113 |
114 if (OSsupportsFeature()) { |
114 if (OSsupportsFeature()) { |
115 print ("running on OS that supports ICMP port unreachable"); |
115 print ("running on OS that supports ICMP port unreachable"); |
116 } |
116 } |
117 String host = "127.0.0.1"; |
117 InetAddress addr = InetAddress.getLoopbackAddress(); |
118 InetAddress addr = InetAddress.getByName(host); |
|
119 DatagramSocket sock = new DatagramSocket(); |
118 DatagramSocket sock = new DatagramSocket(); |
120 DatagramSocket serversock = new DatagramSocket(0); |
119 DatagramSocket serversock = new DatagramSocket(0); |
121 DatagramPacket p; |
120 DatagramPacket p; |
122 byte[] buf; |
121 byte[] buf; |
123 int port = serversock.getLocalPort (); |
122 int port = serversock.getLocalPort (); |