Any ideas why the compiler keeps pissing about an illegal start of type at while(true){? I compile this class under the command line system compiler and using Eclipse and i keep getting the same results.
Code:import java.io.*; import java.net.*; class Server{ private ServerSocket ser; private Socket soc; private OutputStreamWriter out; private int port; public Server(int port){ this.port = port; try{ ser = new ServerSocket(port); }catch(IOException e){ System.out.println("Port" + ser.getLocalPort() + "is occupied"); } } while(true){ try{ soc = ser.accept(); out = new OutputStreamWriter(soc.getOutputStream()); out.write("port open \r\n"); soc.close(); }catch(IOException e){ /* transitory exception\client broke the connection early */ } } }





Reply With Quote