title: Accepting client request with server Socket
body: <p>I am trying creating a socket connection to a web server. </p>
  
  <pre><code>import java.io.IOException;
  import java.io.PrintWriter; 
  import java.net.ServerSocket;
  import java.net.Socket;
  
  
  public class Connection{
  public final static int PORT = 1337;
  
  public Connection(){
      ServerSocket svrSocket = null;
      try{
          svrSocket = new ServerSocket(PORT);
          System.out.println("Conected to: " + PORT);
          Socket con  =  null;
          while(true)
          {
              try{
                  con = svrSocket.accept();//on this part the program stops
                  System.out.println("Client request accepted");
                  PrintWriter out = new PrintWriter(con.getOutputStream());
  
                  out.flush();
              }catch(IOException ex)
              {
                  ex.printStackTrace();
  
              }
          }
      }catch(IOException ex)
      {
          System.err.println(ex);
          System.out.println("Unable to attach to port");
      }
  
  
  }
  }
  </code></pre>
  
  <p>The client request <code>con = svrSocket.accept();</code> does not run. I say this because the message after this line does not display.</p>
  
  <p>Why does it not accept the client request and is it possible to test the Server using a Web browser? Please excuse my bad programming style.</p>
  
  <p>Thank you.</p>