Powered by Ajaxy
Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Java: How to create DatagramPacket from byte array

Java: How to create DatagramPacket from byte array
{filelink=8996}

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
class Ex_Datagramme
 {
  public static void main(String args[]) throws Exception
  {
    InetAddress IP = InetAddress.getByName("127.0.0.1");
    int port = 655;
    // Create a datagram socket
    DatagramSocket ds = new DatagramSocket();
    while (true)
    {
     // Create a message and send it as a datagram
      String str = "welcom to tubedir.com";
      byte buff[] = str.getBytes();
      DatagramPacket dp = new DatagramPacket(buff, buff.length, IP, port);
      ds.send(dp);
    }
  }
}

Users who found this page were searching for:

  • how to build array of bytes in java
  • building a byte array packet java
  • receive file as datagram packet
  • select Jbutton java swing
  • perl random value from array
  • array string to datagram
  • python if while key press
  • python bind
  • java print underline
  • check if an element exists in a dictionary python

No comments yet.

Leave a Comment