Package

Source Code of SendMessage

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.io.IOException;
import java.net.InetAddress;


public class SendMessage{

  public static void main(String[] argv){
     //faire un tableau buffer qui comporte tout les parametre et dans datagrampacket on met just le tableau buffer
  try {
    //String message = new String("Hello") ;
    InetAddress IP_dest = InetAddress.getByName(argv[0]);
    int port_dst = Integer.parseInt(argv[1]);

   
    byte[] to_send = argv[2].getBytes() ;
    //int port_notif = Integer.parseInt(argv[3]);

   
   
      DatagramPacket outPacket = new DatagramPacket(to_send, to_send.length,IP_dest,port_dst);
      DatagramSocket socket = new DatagramSocket() ;
      socket.send(outPacket) ;
  } catch (IOException e) {
      System.out.println("oups") ;
  }

    }
}
TOP

Related Classes of SendMessage

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.