1 // Tags: not-a-test |
|
2 |
|
3 /* |
|
4 Copyright (C) 1999 Hewlett-Packard Company |
|
5 |
|
6 This file is part of Mauve. |
|
7 |
|
8 Mauve is free software; you can redistribute it and/or modify |
|
9 it under the terms of the GNU General Public License as published by |
|
10 the Free Software Foundation; either version 2, or (at your option) |
|
11 any later version. |
|
12 |
|
13 Mauve is distributed in the hope that it will be useful, |
|
14 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 GNU General Public License for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
|
19 along with Mauve; see the file COPYING. If not, write to |
|
20 the Free Software Foundation, 59 Temple Place - Suite 330, |
|
21 Boston, MA 02111-1307, USA. |
|
22 */ |
|
23 // ****************************************************** |
|
24 // |
|
25 // ****************************************************** |
|
26 |
|
27 package gnu.testlet.java.net.DatagramSocket; |
|
28 import gnu.testlet.TestHarness; |
|
29 import java.net.*; |
|
30 import java.io.*; |
|
31 |
|
32 // mod for "equals" and remove dependency on NodeTest |
|
33 |
|
34 class DatagramSocketTestEchoTimeoutServer extends Thread { |
|
35 |
|
36 protected static TestHarness harness; |
|
37 |
|
38 public void run() { |
|
39 try { |
|
40 DatagramSocket sock = new DatagramSocket( 8001 ); |
|
41 |
|
42 byte[] inbuf = new byte[10]; |
|
43 DatagramPacket request = new DatagramPacket(inbuf, inbuf.length); |
|
44 try { |
|
45 { |
|
46 sock.receive(request); |
|
47 // System.out.println("Received request "+ "Data: "+(new String(request.getData()))); |
|
48 DatagramPacket pack = new DatagramPacket( inbuf , 10, |
|
49 InetAddress.getLocalHost() , |
|
50 request.getPort()); |
|
51 |
|
52 // System.out.println("Sending packet back "+ "Data: "+(new String(pack.getData()))); |
|
53 |
|
54 sock.send(pack); |
|
55 } |
|
56 } catch (IOException e) { |
|
57 System.out.println("Error : run failed with IOException " ); |
|
58 e.printStackTrace(); |
|
59 } |
|
60 |
|
61 }catch ( Exception e ) |
|
62 { |
|
63 System.out.println("Error : run failed with exception " ); |
|
64 e.printStackTrace(); |
|
65 } |
|
66 } |
|
67 } |
|