Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Udp Server

By: godens on Mar 2nd, 2013  |  syntax: Java  |  size: 0.56 KB  |  views: 36  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. public class Server {
  2.        
  3.         public static void main(String[] args) throws IOException {
  4.                
  5.                 //test case flow
  6.                 byte[] sendData = new byte[50];
  7.                 DatagramSocket sendSock = new DatagramSocket();
  8.                 ServerSocket socket = new ServerSocket(57111);
  9.                                 sendData = "server msg here".getBytes("UTF-8");
  10.                                 sendSock.connect(InetAddress.getByName("10.0.2.15"), 57111);
  11.                                 DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length,InetAddress.getByName("10.0.2.15"), 57111);
  12.                                         sendSock.send(sendPacket);
  13.                                         System.out.println("pack sent");
  14.                
  15.         }
  16. }