]> git.somenet.org - pub/jan/dslab.git/blob - ue1/src/Server/UDP.java
GITOLITE.txt
[pub/jan/dslab.git] / ue1 / src / Server / UDP.java
1 package Server;\r
2 \r
3 import java.io.*;\r
4 import java.util.*;\r
5 import java.net.*;\r
6 \r
7 /*\r
8 * >--SyslogD_UDP--<\r
9 * Author: Someone\r
10 */\r
11 public class UDP implements Runnable{\r
12   private DatagramSocket $udpSock       = null;\r
13 \r
14 public UDP(int $port)throws Exception{\r
15   $udpSock = new DatagramSocket($port);\r
16   $udpSock.setReceiveBufferSize(1024*1024);\r
17   new Thread(this).start();\r
18 }\r
19 \r
20 public void run(){\r
21   while($udpSock != null){\r
22     receive();\r
23   }\r
24 }\r
25 \r
26 public void receive(){\r
27   try{\r
28     DatagramPacket $packet = new DatagramPacket(new byte[1400],1400);\r
29     $udpSock.receive($packet);\r
30     new UDPW($packet,$udpSock);\r
31   }catch(Exception $e){$e.printStackTrace();}\r
32 }\r
33 \r
34 public void shutdown(){\r
35   try{\r
36     $udpSock.close();\r
37   }catch(Exception $e){$e.printStackTrace();}\r
38   $udpSock=null;\r
39 }\r
40 }