import java.net.*; import java.io.*; public class SimpleServer { public static void main(String args[]) { ServerSocket s = null; Socket s1; String sendString = "Hello Net World!"; OutputStream os; DataOutputStream dos; try { s = new ServerSocket(5432); } catch (IOException e) { } while (true) { try { // wait here and listen for a connection s1 = s.accept(); //Get a communication stream associated with the socket os = s1.getOutputStream(); dos = new DataOutputStream (os); //Send your string! (UTF provides machine independence) dos.writeUTF(sendString); // close the connection, but not the server socket dos.close(); os.close(); s1.close(); } catch (IOException e) { // ignore } } } }