+
+ private void bgTask() {
+ DatagramSocket s = null;
+ try {
+ s = new DatagramSocket(9999);
+ } catch (java.net.SocketException e) {
+ println("socket: " + e);
+ return;
+ }
+// InetSocketAddress sa = new InetSocketAddress(9999);
+// try {
+// s.bind(sa);
+// } catch (IllegalArgumentException e) {
+// println("bind: " + e);
+// return;
+// } catch (java.net.SocketException e) {
+// println("bind: " + e);
+// return;
+// }
+ println("Bound to port " + s.getLocalPort());
+ while (true) {
+ byte[] data = new byte[256];
+ DatagramPacket pkt = new DatagramPacket(data, 256);
+ try {
+ s.receive(pkt);
+ } catch (java.io.IOException e) {
+ println("receive: " + e);
+ }
+ InetAddress ia = pkt.getAddress();
+ int ip = pkt.getPort();
+ byte[] id = pkt.getData();
+ println(ia.toString() + ":" +
+ ip + " " +
+ id.toString());
+ }
+ }