Code example for DatagramSocket

Methods: setBroadcast

0
	 
	private InetAddress host;
	private int port;
	 
	public PacketCannon(String host, int port) throws SocketException, UnknownHostException {
		ds = new DatagramSocket();
		ds.setBroadcast(true);
		 
		this.host = InetAddress.getByName(host);
		this.port = port;
	} 
	 
	public void sendPacket(String... data){
		new SendPackets().execute(data);
	} 
	 
	private class SendPackets extends AsyncTask<String, Void, Void> {
		@Override 
		protected Void doInBackground(String... arg0) {
			for(String packet : arg0){
				sendString(packet);