Monte carlo server program
<pre><code>package montecarlo;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Scanner;

/**
 *
 * @author hafiz
 */
public class PICalcDistributedMaster {

ObjectOutputStream ostream;
ObjectInputStream istream;
Socket s;
String numThrows;

  public void go(){

          Scanner input = new Scanner(System.in);
          System.out.println("Please enter number of throws: ");
          numThrows = input.next();
          int num = Integer.parseInt(numThrows);

          try{
               ServerSocket sock = new ServerSocket(100);
               s = new Socket("127.0.0.1",100);
               System.out.println("Waiting for connection");
               System.out.println("Connection received from " + s.getInetAddress());

               PrintWriter pw = new PrintWriter(s.getOutputStream(),true);
               pw.println("Sending Number");
               pw.println(num);

               ostream = new ObjectOutputStream(s.getOutputStream());
               ostream.flush();

               istream = new ObjectInputStream(s.getInputStream());
               System.out.println("IO streams found");
               istream.read(); //reads the input stream

             }

          catch (IOException ie){
              ie.printStackTrace();
          }
   }

   public static void main(String [] args){
       PICalcDistributedMaster pim = new PICalcDistributedMaster();
       pim.go();

   }
</code></pre>

<p>}</p>

<p>i have adjusted the code to what you told me.I am still getting an error after running it more than once and i think it has to do with the garbage collector problem.My error is </p>

<pre><code>java.net.SocketException: Unrecognized Windows Sockets error: 0: JVM_Bind
    at java.net.PlainSocketImpl.socketBind(Native Method)
    at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:365)
    at java.net.ServerSocket.bind(ServerSocket.java:319)
    at java.net.ServerSocket.&lt;init&gt;(ServerSocket.java:185)
    at java.net.ServerSocket.&lt;init&gt;(ServerSocket.java:97)
    at montecarlo.PICalcDistributedMaster.go(PICalcDistributedMaster.java:31)
    at montecarlo.PICalcDistributedMaster.main(PICalcDistributedMaster.java:56)
</code></pre>

<p>I assume the problem is with the socket it is binding to.I have tried different kinds but i cant still proceed</p>
