Results 1 to 5 of 5

Thread: illegal start of type?{resolved}

  1. #1

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Angry 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.

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.

  3. #3

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    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.

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.

  5. #5

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    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
  •  



Click Here to Expand Forum to Full Width