title: I/O Socket error (Java)
body: <p>I have a problem using a socket:</p>
  
  <pre><code>        socket = new Socket(hostname, port);
          os = socket.getOutputStream();
          oos = new ObjectOutputStream(os);
          is = socket.getInputStream();
          ois = new ObjectInputStream(is);  // THIS ALWAYS RAISES EXCEPTION
  </code></pre>
  
  <p>I have checked "is" is not null (with println):
  java.net.SocketInputStream@403a7c5e</p>
  
  <p>The IOexception message is: null</p>
  
  <pre><code>java.io.EOFException
          at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2297)
          at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2766)
          at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:797)
          at java.io.ObjectInputStream.&lt;init&gt;(ObjectInputStream.java:297)
          at com.my.Comunication.sendData(Netw.java:140)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:616)
          at com.sun.xml.ws.api.server.InstanceResolver$1.invoke(InstanceResolver.java:246)
          at com.sun.xml.ws.server.InvokerTube$2.invoke(InvokerTube.java:146)
          at com.sun.xml.ws.server.sei.EndpointMethodHandler.invoke(EndpointMethodHandler.java:257)
          at com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:95)
          at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:629)
          at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:588)
          at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:573)
          at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:470)
          at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:295)
          at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:515)
          at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:285)
          at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:143)
          at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doGet(WSServletDelegate.java:155)
          at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doPost(WSServletDelegate.java:189)
          at com.sun.xml.ws.transport.http.servlet.WSServlet.doPost(WSServlet.java:76)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
          at java.lang.Thread.run(Thread.java:636)
  </code></pre>
  
  <p>Does anybody know what is going on? Thanks.</p>
  
  <p>EDIT:  The object is an ObjectInputStream</p>