Biblioteca Java - Blame information for rev 3

Subversion Repositories:
Rev:
Rev Author Line No. Line
3 mihai 1 /*
2  * QuoteClient.java
3  */
4 package lab.scd.net.datagrame;
5  
6 /**
7  * Class created by @author Mihai HULEA at Feb 23, 2005.
8  *
9  * This class is part of the laborator2_sockettest project.
10  *
11  */
12 import java.io.*;
13 import java.net.*;
14  
15  
16 public class QuoteClient {
17  
18     public static void main(String[] args) throws IOException {
19  
20         /*
21         if (args.length != 1) {
22              System.out.println("Usage: java QuoteClient <hostname>");
23              return;
24         }
25 */
26             // get a datagram socket
27         DatagramSocket socket = new DatagramSocket();
28  
29             // send request
30         byte[] buf = new byte[256];
31         InetAddress address = InetAddress.getByName("localhost");
32         DatagramPacket packet = new DatagramPacket(buf, buf.length, address, 4445);
33         socket.send(packet);
34  
35             // get response
36         packet = new DatagramPacket(buf, buf.length);
37         socket.receive(packet);
38  
39             // display response
40         String received = new String(packet.getData());
41         System.out.println("Quote of the Moment: " + received);
42  
43         socket.close();
44     }
45  
46  
47 }