Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1616 | boinc | 1 | import java.net.*; |
2 | import java.util.*; |
||
3 | |||
4 | public class DatagramSender { |
||
5 | public static void main(String argv[]) throws Exception { |
||
6 | long i = 0; |
||
7 | DatagramSocket sender = new DatagramSocket(); |
||
8 | InetAddress IP = InetAddress.getByName("192.168.121.2"); |
||
9 | String line=("Inviato"); |
||
10 | byte[] buffer = new byte[255]; |
||
11 | byte[] buffer1 ; |
||
12 | DatagramPacket packetr; |
||
13 | |||
14 | while ( true ) { |
||
15 | //DatagramPacket packet = new DatagramPacket(buffer, buffer.length); |
||
16 | //System.out.println("In attesa di messaggi..."); |
||
17 | //receiver.receive(packet); |
||
18 | //String message = new String(packet.getData(), packet.getOffset(), packet.getLength()); |
||
19 | //System.out.println("Messaggio ricevuto dall'host " + packet.getAddress() + " su porta " + packet.getPort() + ": " + message+" "+ i++); |
||
20 | line="Inviato"+i; |
||
21 | buffer1 = line.getBytes(); |
||
22 | packetr = new DatagramPacket(buffer1, buffer1.length, IP, 100); |
||
23 | sender.send(packetr); |
||
24 | if(i++ % 10==0) |
||
25 | System.out.println("Inviato"+i); |
||
26 | Thread.sleep(508,0); |
||
27 | |||
28 | //System.out.println(message+" "+ i++); |
||
29 | } |
||
30 | |||
31 | } |
||
32 | } |
||
33 | |||
34 | |||
35 |