title: problem with sockets in java
body: <p>I have the following thread which accepts for incoming connections at a specific port:</p>
  
  <pre><code>public class ClientThread implements Runnable {
      ServerSocket serverSocket;
      Socket clientSocket;
      int serverPort = 6500;
      private String serverIpAddress = "127.0.0.1";
      DataInputStream is;
      ObjectOutputStream os=null;
      Coordinate coord;
  
      protected BlockingQueue queue = null;
  
      public ClientThread(BlockingQueue queue) {
          this.queue = queue;
      }
  
      public void run() {
          try {
              InetSocketAddress serverAddr = new InetSocketAddress(
                      serverIpAddress, serverPort);
              serverSocket = new ServerSocket();
              serverSocket.bind(serverAddr);
              System.out.println("s-a creat");
          } catch (UnknownHostException e) {
              System.err.println("Don't know about host");
          } catch (IOException e) {
              System.err.println("Couldn't get I/O for the connection to host");
          }
  
          try {
              clientSocket = serverSocket.accept();
              System.out.println("S-a conectat clientul de monitorizare!");
  
              os=new ObjectOutputStream(clientSocket.getOutputStream());
              try{
                  while(true){
                      coord=(Coordinate)queue.take();
                      System.out.println(coord.getLat()+coord.getLon()+coord.getwId());
                      os.writeObject(coord);
                      os.flush();
                  }
              } catch(Exception e) {
                  e.printStackTrace();
              }
          } catch (IOException e) {
              System.out.println(e);
  
              try {
                  clientSocket.close();
                  os.close();
              }catch(Exception e1) {
                  e1.printStackTrace();
              }
          }
      }
  }
  </code></pre>
  
  <hr>
  
  <p>The object I'm trying to send is an instance of the following class:</p>
  
  <pre><code>public class Coordinate implements Serializable{
      private final int lon;
      private final int lat;
      private final int workerId;
  
      public Coordinate(int lat, int lon, int workerId) {
          this.lat = lat;
          this.lon = lon;
          this.workerId=workerId;
      }
  
      public int getLon() {
          return lon;
      }
  
      public int getLat() {
          return lat;
      }
  
      public int getwId() {
          return workerId;
      }
  }
  </code></pre>
  
  <hr>
  
  <p>But when I start the thread and I accept for connection I get the following error:</p>
  
  <pre><code>java.net.SocketException: Software caused connection abort: socket write error
      at java.net.SocketOutputStream.socketWrite0(Native Method)
      at java.net.SocketOutputStream.socketWrite(Unknown Source)
      at java.net.SocketOutputStream.write(Unknown Source)
      at java.io.ObjectOutputStream$BlockDataOutputStream.drain(Unknown Source)
      at java.io.ObjectOutputStream$BlockDataOutputStream.setBlockDataMode(Unknown 
      at java.io.ObjectOutputStream.writeNonProxyDesc(Unknown Source)
      at java.io.ObjectOutputStream.writeClassDesc(Unknown Source)
      at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
      at java.io.ObjectOutputStream.writeObject0(Unknown Source)
      at java.io.ObjectOutputStream.writeFatalException(Unknown Source)
      at java.io.ObjectOutputStream.writeObject(Unknown Source)
      at servers.ClientThread.run(ClientThread.java:55)
      at java.lang.Thread.run(Unknown Source)
  </code></pre>
  
  <hr>
  
  <p>Anyone anyidea of what is wrong?</p>
  
  <hr>
  
  <p>This error  java.net.SocketException: Software caused connection abort appears when one of the socket end crashes....in my case was the end that connected to ClientThread() and when I was trying to write in the buffer the error appeared.</p>