package Server;

import java.io.*;
import java.util.*;
import java.net.*;

/*
* >--SyslogD_UDP--<
* Author: Someone
*/
public class UDP implements Runnable{
  private DatagramSocket $udpSock	= null;

public UDP(int $port)throws Exception{
  $udpSock = new DatagramSocket($port);
  $udpSock.setReceiveBufferSize(1024*1024);
  new Thread(this).start();
}

public void run(){
  while($udpSock != null){
    receive();
  }
}

public void receive(){
  try{
    DatagramPacket $packet = new DatagramPacket(new byte[1400],1400);
    $udpSock.receive($packet);
    new UDPW($packet,$udpSock);
  }catch(Exception $e){$e.printStackTrace();}
}

public void shutdown(){
  try{
    $udpSock.close();
  }catch(Exception $e){$e.printStackTrace();}
  $udpSock=null;
}
}