Back to project page Android-Wireless.
The source code is released under:
MIT License
If you think the Android project Android-Wireless 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 com.Nimble.Server; // w w w . j a va2 s.c o m import java.io.IOException; import java.net.ServerSocket; import java.net.Socket; import android.util.Log; /** * Class to start a pingback server on a given port. * @author Michael Leith * */ public class Server extends Thread{ private static int port; private ServerSocket serverSocket; public Server(final int portAddress) { port = portAddress; } public void run() { try { serverSocket = new ServerSocket(port); for(;;) new ThreadHandler( serverSocket.accept() ).start(); } catch (IOException e) { Log.e(this.getClass().toString(), e.toString()); } } class ThreadHandler extends Thread { Socket socket; public ThreadHandler(Socket s) { socket = s; } public void run() { try{ // Read byte[] input = Sockets.read(socket); // Reply Sockets.write(socket, input); socket.close(); } catch (Exception e) { Log.e("Client Thread", e.toString()); } } } }