title: Connection refused when trying to set up a simple Client Server system
body: <p>I'm getting </p>
  
  <pre><code>Exception in thread "main" java.net.ConnectException: Connection 
  </code></pre>
  
  <p>whenever I try to start the server in this simple system I have setup. The code is just basically copied from a tutorial in which it ran perfectly, so I can only assume this is some enviormental issue which I am encountering (MAC OSX 10.10.5 / Netbeans)</p>
  
  <p>Here are my classes:</p>
  
  <p>Client:</p>
  
  <pre><code>public class Client
  {
     public static void main(String [] args) throws UnknownHostException, IOException
     {
         int number,temp;
         Scanner sc = new Scanner(System.in);
         Socket s = new Socket("127.0.0.1",1342);
         Scanner sc1 = new Scanner(s.getInputStream());
         System.out.println("Print any number:");
         number = sc.nextInt();
         PrintStream p = new PrintStream(s.getOutputStream());
         p.println(number);
         temp = sc1.nextInt();
         System.out.println(temp);
  
  
     }
  }
  </code></pre>
  
  <p>Server:</p>
  
  <pre><code>public class Server 
  {
      public static void main (String args[]) throws IOException{
  
          int number,temp;
          ServerSocket s1 = new ServerSocket(1342);
          Socket ss= s1.accept();
          Scanner sc = new Scanner(ss.getInputStream());
          number=sc.nextInt();
  
          temp = number*2;
  
          PrintStream p = new PrintStream(ss.getOutputStream());
          p.println(temp);   
      }
  }
  </code></pre>
  
  <p>Does anybody have any ideas on what I am ding wrong, or whats wrong with my setup?</p>