|
-
Nov 19th, 2003, 01:31 AM
#1
Thread Starter
Dazed Member
illegal start of type?{resolved}
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
*/
}
}
}
Last edited by Dilenger4; Nov 25th, 2003 at 01:24 AM.
-
Nov 19th, 2003, 06:29 AM
#2
Presentable case of formatting error 
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
*/
}
}
}
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Nov 19th, 2003, 11:29 AM
#3
Thread Starter
Dazed Member
So what is the problem? All the brackets seem to be in the correct location.
Last edited by Dilenger4; Nov 19th, 2003 at 04:53 PM.
-
Nov 19th, 2003, 03:01 PM
#4
Get glasses and look closely! The while loop is outside the function!
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Nov 19th, 2003, 04:54 PM
#5
Thread Starter
Dazed Member
eeek. I must be going crazy. Thanks.
Last edited by Dilenger4; Nov 20th, 2003 at 01:06 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|