A Better Server

try {
 ServerSocket ss = new ServerSocket(2345);
 Socket s = ss.accept();
 Writer out = new BufferedWriter(
               new OutputStreamWriter(s.getOutputStream(), "UTF-8")
              );
 out.write("Hello There!\r\n");
 out.write("Goodbye now.\r\n");
 out.flush();
 s.close();
}
catch (IOException ex) {
 System.err.println(ex);
}

Previous | Next | Top | Cafe con Leche

Copyright 2003 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified February 13, 2003