Back to project page Spidermine.
The source code is released under:
Copyright ? 2014 PEMapModder This software is open-source and everyone is welcome to share redistributions or modifications, as long as it is clearly specified that this project's original source is ...
If you think the Android project Spidermine listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package pemapmodder.spidermine.network; /* w w w . j av a2s . c o m*/ import java.io.IOException; import java.net.DatagramPacket; import java.net.DatagramSocket; import java.net.SocketException; import pemapmodder.spidermine.SpiderServer; import pemapmodder.spidermine.network.packet.PacketParser; public class NetworkHandler extends Thread{ public DatagramSocket socket=null; public DatagramPacket packet=null; public final SpiderServer server; public NetworkHandler(SpiderServer server){ this.server=server; try{ socket=new DatagramSocket(server.getIp()); }catch(SocketException e){ server.console.out("[SEVERE ERROR] SpiderMine is unable to create socket via address "+server.getIp().toString()+". Server starting aborted."); } } @Override public synchronized void start(){ super.start(); while(server.status==SpiderServer.STATUS_STARTED){ byte[] buffer=new byte[2048]; packet=new DatagramPacket(buffer, buffer.length); try{ socket.receive(packet); }catch(IOException e){ e.printStackTrace(); } PacketParser parser=new PacketParser(packet.getData()); } } }