Java tutorial
import java.net.ServerSocket; import java.net.Socket; class MTServerBase extends Thread { Socket socket; public void run() { try { String s = "I'm a server."; socket.getOutputStream().write(s.getBytes()); socket.close(); } catch (Exception e) { System.out.println(e); } } static public void main(String args[]) throws Exception { ServerSocket ssock = new ServerSocket(8080); while (true) { Socket esock = null; esock = ssock.accept(); MTServerBase t = new MTServerBase(); t.socket = esock; t.start(); esock.close(); } } }