Code example for MulticastSocket

Methods: close, send

0
		 * @see android.os.AsyncTask#doInBackground(Params[]) 
		 */ 
		@Override 
		protected Void doInBackground(String... params) {
			try { 
				MulticastSocket s = new MulticastSocket();
				try { 
					// Log.d(TAG, "UDP command, port"+ port); 
					String msg = params[0];
					InetAddress group = InetAddress.getByName(address);
					DatagramPacket p = new DatagramPacket(msg.getBytes("UTF-8"), msg.length(), group, port);
					s.send(p);
				} catch (Exception e) {
					Log.e(TAG, "UDP error " + e.toString());
				} finally { 
					s.close();
				} 
			} catch (Exception e) {
				e.printStackTrace();
			} 
			return null;