-
Notifications
You must be signed in to change notification settings - Fork 0
/
MultiSend.java
36 lines (30 loc) · 872 Bytes
/
MultiSend.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author rahul
*/
import java.net.InetAddress;
import java.net.*;
import java.io.*;
import java.util.*;
public class MultiSend implements Runnable{
public static void main(String args[]) throws IOException
{
}
public static void sendData(String data, String groupid, int port) throws IOException{
MulticastSocket socket=new MulticastSocket(port);
byte[] buffer = data.getBytes();
InetAddress group = InetAddress.getByName(groupid);
DatagramPacket datagram = new
DatagramPacket(buffer,buffer.length,group,port);
socket.send(datagram);
}
@Override
public void run()
{
}
}