Open an input stream to a socket

How many times I can open an input stream to a socket? If I create more than one an input stream to a socket, does this affect anything?
Thanks.

Generally low level classes do not have high level logic. Socket is a low level class, it's only logic is to connect you to something, and allow you to read and write to that thing (through the socket) using streams. Being able to connect multiple times or setting marks on your stream is a higher level of logic. Putting to much logic is low level classes tends to reduce re-useablility (making unmarkable streams markable as nothing to do with sockets and can be re-used upon any streams that do not support to be marked) and sometimes performances (having marks means having a buffer means having a potential big memory allocation in your Socket that you do not control).
So in your case, since you are not really interested in re-connecting a socket, you should rather go for a wrapping InputStream that provides marking capabilities over the streams used by the socket class itself.
   Socket socket = getSocket();
   // this one does not support to be marked
   InputStream stream = socket.getInputStream();
   // but now it does :)
   stream = new BufferedInputStream( stream );

Similar Messages

  • Multiple input stream in one socket connection

    Can we have multiple input streams for a java socket connection? It means that in a client/server application (creates using java socket), can we have multiple input streams for the client side program. For example, the input streams are to cater for the need of letting the user to chat and downloading some files from the chat partner at the same time. And do we need to use thread to create the multiple input streams like the case when we create a multithreaded server? Anyone out there who knows the solution please post it. Thanks in advance.

    Can we have multiple input streams for a java socket
    connection? It means that in a client/server
    application (creates using java socket), can we have
    multiple input streams for the client side program.
    For example, the input streams are to cater for the
    need of letting the user to chat and downloading some
    files from the chat partner at the same time. And do
    we need to use thread to create the multiple input
    streams like the case when we create a multithreaded
    server? Anyone out there who knows the solution please
    post it. Thanks in advance.Ok im no expert here but this is what i learned:
    a Socket can have only one InputStream (Socket.getInputStream()) and one OutputStream Socket.getOutputStream()). So you will have to create a way to make multiple Socket connections in your client program. And yes, you have to use threads for your server. if you dont the client will have to wait until the user before them is finished with the connection before being able to connect. I hope this helps you out. BTW please check out http://www.javabible.com. they have the book online now for free.
    Joeyford1

  • Parsing input stream from a socket

    Hi, i must read a byte stream from a socket. My problem is that i cannot determine when a stream ends because there are no terminator characters. I tried to use the read() method of BufferedReader class but it blocks when server statement ends. Is there a way to read the stream and answer to the server?
    Thanks,
    Andrea

    andmus wrote:
    Hi, i must read a byte stream from a socket. My problem is that i cannot determine when a stream ends because there are no terminator characters. I tried to use the read() method of BufferedReader class but it blocks when server statement ends. Is there a way to read the stream and answer to the server?
    If you're reading HTTP...
    Unless the request has been sent with Connection: close, it's normal that your read blocks, since the connection is purposefully left open to accomodate further exchanges.
    You'll have to parse the data to know when each message is complete. The first empty line (bytes: \r\n\r\n ASCII) denotes the end of the header. The header will have a Content-Length property which tells you how many bytes are left to read.
    Google the HTTP specs if you don't know them.

  • Reading input stream over the tcp socket in unix

    I have a program that reads data from input stream from the socket. If the data is over 1500 bytes it is sent in multiple TCP packets. Whats weird is, if I run the program in windows environment it waits till it receives all the packets but when I run the same program in unix environment it only reads the first packet and go further without waiting for all the TCP packets!!
    The line that reads from input stream is
    datalen = inStr.read(byteBuffer);is there anyway I can make it wait till it receives all the packets on unix system? I do not understand why it works fine for windows in this case but not for unix.
    I'll appreciate any help..
    Thanks

    When the network is busy there can be any amount of dleay between packets. If this is ever 100 ms , then this will break.
    If you send more than one packet per 100 ms you will get two packets at once which will look like one longer packet. Unless you check for this the second packet may get ignored.
    The safe way is to send the packet size before sending the packet. Then on the client read the packet to the correct length. Otherwise you will have a program which just happens to work rather than one which will always work.

  • Reading data from input stream on unix

    I have a program that reads data from input stream from the socket. If the data is over 1500 bytes it is sent in multiple TCP packets. Whats weird is, if I run the program in windows environment it waits till it receives all the packets but when I run the same program in unix environment it only reads the first packet and go further without waiting for all the TCP packets!!
    The line that reads from input stream is
    datalen = inStr.read(byteBuffer);is there anyway I can make it wait till it receives all the packets on unix system? I do not understand why it works fine for windows in this case but not for unix.
    I'll appreciate any help..
    Thanks

    Try using a DataInputStream with the readfully() method.

  • Input streams kill my applet

    This is probably a little thing that I have forgotten but I can't for the life of me get. Ok I should probably say I am running XP, with Java 1.5 and Firefox
    I have an applet that works fine on Eclipse but when I try to run it by it self it seems to die at the point where I have my input streams.
    Basicly I have included the test code that removes all the input processing and tree building. This test script below just opens a input stream, creates a tree with two nodes and displays the tree. If you remove any the 3 TRYS it will not work.
    I have tried various methods to read in the URL I have but it seems to die every time. I have included the code below. If anyone has any suggestions I would greatly appreciate it.
    Thanks
    Luis
    import java.applet.AppletContext;
    import java.awt.Color;
    import java.awt.Font;
    import java.io.DataInputStream;
    import java.io.InputStream;
    import java.net.*;
    import java.io.*;
    import javax.swing.JApplet;
    import javax.swing.JLabel;
    import javax.swing.JScrollPane;
    import javax.swing.JTree;
    import javax.swing.event.TreeSelectionEvent;
    import javax.swing.event.TreeSelectionListener;
    import javax.swing.tree.DefaultMutableTreeNode;
    import javax.swing.tree.TreePath;
    import java.net.URLConnection;
    public class TestApplet extends JApplet{
         // Variables used by the applet
         protected JTree jt;
         protected URL url;
         public void init() {
              setBackground(Color.lightGray);
              setFont(new Font("Verdana", Font.BOLD, 12));
              try{
              url = new URL("http://www.yahoo.com");
              //IF I REMOVE ANY OF THE FOLLOWING COMMENTS IT DOES NOT WORK
              //TRY 1.  IF REMOVED IT WILL NOT WORK
              /*     URL yahoo = new URL("http://www.yahoo.com/");
                   BufferedReader in = new BufferedReader(yahoo.openStream());
                   String inputLine;
                   while ((inputLine = in.readLine()) != null)
                       System.out.println(inputLine);
                   in.close();
              //TRY 2.  IF REMOVED IT WILL NOT WORK
              /*     URLConnection connection = url.openConnection();
                InputStream in = connection.getInputStream();
                   DataInputStream stream = new DataInputStream(in);
              //TRY 3.  IF REMOVED IT WILL NOT WORK
              //BufferedReader stream = new BufferedReader(new InputStreamReader(url.openStream()));
              DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(url);
             rootNode.add(new DefaultMutableTreeNode("Child 1"));
              JTree jt = new JTree(rootNode);
              // Tree Setup
              jt.setExpandsSelectedPaths(true);
              jt.setVisible(true);
              jt.putClientProperty("JTree.lineStyle", "Angled");
              getContentPane().removeAll();
              getContentPane().add(jt);
              //stream.close();
              //iStream.close();
              } catch (Exception e) {
                   e.printStackTrace();
         public void start() {
    }// end TreeApplet Class

    You are right on the money about the applet viewer working and the security errors I am getting. Look below this is from the console.
    java.security.AccessControlException: access denied (java.net.SocketPermission www.reservhotel.com:80 connect,resolve)
         at java.security.AccessControlContext.checkPermission(Unknown Source)
         at java.security.AccessController.checkPermission(Unknown Source)
         at java.lang.SecurityManager.checkPermission(Unknown Source)
         at java.lang.SecurityManager.checkConnect(Unknown Source)
         at sun.net.www.http.HttpClient.openServer(Unknown Source)
         at sun.net.www.http.HttpClient.<init>(Unknown Source)
         at sun.net.www.http.HttpClient.New(Unknown Source)
         at sun.net.www.http.HttpClient.New(Unknown Source)
         at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
         at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
         at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
         at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
         at RHMenu.start(RHMenu.java:80)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    I understand that the applet cannot connect to a server other than the one it is connected to but shouldn't I be able to connect to "www.yahoo.com"? I tried putting the URL and open stream in the start thread but it does not seem to work. When I run it in a web browser, the Java Sun comes up and it says it is inited and started but nothing comes up. Any ideas?
    Thanks,
    Luis

  • Unexpected end of ZLIB input stream error while compiling

    Hello
    I am getting errors when i run RMIC and JAR apps in the same window, i've tried to close and open the input stream in between, tried delaying between the two , tried /I paramaeter, any one ?
    Rmic stage pass OK
    but i get Unexpected end of ZLIB input stream exception i some of the file on the jar stage :
    Main batch :
    start /B %SWIFT_LOCAL_HOME%\scripts\rmicAll.bat
    start /B %SWIFT_LOCAL_HOME%\scripts\create_jar.bat
    Jar exception :
    adding: CVS/(in = 0) (out= 0)(stored 0%)
    adding: CVS/Entries(in = 383) (out= 168)(deflated 56%)
    adding: CVS/Repository(in = 13) (out= 15)(deflated -15%)
    adding: CVS/Root(in = 60) (out= 60)(deflated 0%)
    java.io.EOFException: Unexpected end of ZLIB input stream
    at java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:223)
    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:141)
    at java.util.zip.ZipInputStream.read(ZipInputStream.java:146)
    at sun.tools.jar.Main.update(Main.java:508)
    at sun.tools.jar.Main.run(Main.java:184)
    at sun.tools.jar.Main.main(Main.java:1022)
    C:\Eclipse_Workspace\Swift\scripts>date /T 1>>C:\Eclipse_Workspace\Swift\swift_build.txt
    C:\Eclipse_Workspace\Swift\scripts>time /T 1>>C:\Eclipse_Workspace\Swift\swift_build.txt
    C:\Eclipse_Workspace\Swift\scripts>echo Swift.jar Build Time : 1>C:\Eclipse_Workspace\Swift\swift_build.txt
    C:\Eclipse_Workspace\Swift\scripts>"C:\Program Files\Java\jdk1.6.0_02\bin\jar" -uvf C:\Eclipse_Workspace\Swift\jars\swift.jar -C C:\Eclipse_Workspace\Swift swift_build.txt
    java.io.EOFException: Unexpected end of ZLIB input stream
    at java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:223)
    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:141)
    at java.util.zip.ZipInputStream.read(ZipInputStream.java:146)
    at sun.tools.jar.Main.update(Main.java:508)
    at sun.tools.jar.Main.run(Main.java:184)
    at sun.tools.jar.Main.main(Main.java:1022)

    You seem to be adding the contents of CVS directories to the jar file. CVS directories contain internal information used by CVS. This suggests to me that you are either deliberately doing something really really strange, or you are doing something stupid out of ignorance.
    The CVS directories suggest you are making a jar from your source code. Generally you compile the source code 'tree' and place the output (.class files etc) in another tree and create the jar from that second tree.
    And PaulMiner is correct, you'll definitely need to change 'start' to 'call'. Do that first, then take a look at what is source code, and what it is that you want in your jar file and make sure it is all sensible, I suspect it isn't.

  • Help with input streams

    hello/
    i need an InputStream for the constructor of my SAXBuilder object below.
    i have this working, however, i would like to read everything from the
    InputStream first and save the value into a String object before I pass the InputStream to the SAXBuilder. how do i go about doing this?
    thx/f
    // Open an input stream to the URL and read it into a byte array.
    BufferedInputStream bufferedInput =
    new BufferedInputStream(connection.getInputStream());
    // Create a new SAX builder.SAXBuilder builder = new SAXBuilder();
    // Read the portal response back and save it as an XML document.
    Document response = builder.build(bufferedInput);

    But you have now read from your input stream and need to reset it so
    InputStream is = urlConn.getInputStream();
    if ( is.markSupported() ) {
       is.reset();
    else {
       is.close();
       is = new ByteArrayInputStream( docStr.toString().getBytes() );
    Now you can pass your InputStream into your SaxBuilder, and have your string of what it contains.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • JVM_recv in socket input stream error

    I've opened a socket and I'm able to access the OutputStream. However, when I try to wrap a ObjectInputStream around the socket's InputStream, I get this error:
    SocketException: Connection reset by peer: JVM_recv in socket input stream read.
    What should I be looking for?
    Larry

    Here's the code which appears to be relevant, with some commentary on what happens when it is run. Large portions of (hopefully) irrelevant code have been snipped.
    Client:
    COMMENT: Start a server using RMI. This appears to
    COMMENT: succeed, since a message printed by this
    COMMENT: server does appear.
    try {
    DistLrnRemoteData dlrd =
    (DistLrnRemoteData)Naming.lookup(
    "//"+personHost+
    "/DistanceLearningData");
    dlrd.activatePersonServer(); // Get server going
    catch (Exception e) {
    System.err.println(e);
    COMMENT: This line is NOT printed, so apparently
    COMMENT: there is no Exception.
    System.err.println("Unable to initialize remote Person server");
    e.printStackTrace(System.err);
    Person result = new Person();
    int count = 10;
    boolean opened = false;
    Socket gpsocket = null;
    while (!opened) {
    try {
    COMMENT: The client attempts to open the socket
    COMMENT: here. The server never seems to accept it,
    COMMENT: but this call appears to succeed. There is
    COMMENT: no Exception. The server is running code
    COMMENT: from the class RemoteDataServer, so the
    COMMENT: port should be the same. The testing was
    COMMENT: done with a single host acting as both
    COMMENT: client and server, so there isn't any firewall
    COMMENT: or network outage problem.
    gpsocket = new Socket(personHost,
    RemoteDataServer.personReadPort);
    opened = true;
    catch (IOException ioe) {
    count--;
    if (count <= 0) {
    COMMENT: This line is NOT printed, so apparently there
    COMMENT: is no IOException when the Socket is
    COMMENT: created. Nor does an UnknownHostException
    COMMENT: or SecurityException stop the program.
    System.err.println(ioe);
    ioe.printStackTrace(System.err);
    result = null;
    return result;
    try {
    Thread.sleep(1000);
    catch (InterruptedException ie) {
    System.err.println(ie);
    ie.printStackTrace(System.err);
    // Read the serialized object
    try {
    COMMENT: No problem with the next line, which attempts
    COMMENT: to access the OutputStream of the socket.
    MyStringWriter msw = new MyStringWriter(
    gpsocket.getOutputStream());
    COMMENT: The next line causes the message.
    ObjectInputStream ois =
    new ObjectInputStream(gpsocket.getInputStream());
    msw.write(personRealName);
    // Now read the resulting Person.
    try {
    result = (Person)(ois.readObject());
    catch (ClassNotFoundException cnfe) {
    System.err.println(cnfe);
    cnfe.printStackTrace(System.err);
    System.exit(4);
    catch (IOException ioe) {
    System.err.println(ioe);
    ioe.printStackTrace(System.err);
    result = null;
    Server:
    public void activateFocusServer() throws java.rmi.RemoteException {
    String [] cmd = new String[2];
    cmd[0] = new String("java");
    cmd[1] = new String("RemoteDataServer");
    try {
    COMMENT: FORTE's Output window shows a message
    COMMENT: from this process
    Process dbserver =
    Runtime.getRuntime().exec(cmd); // Server will self-destruct
    // after a timeout period
    catch (IOException ioe) {
    COMMENT: This message is never printed
    System.err.println(ioe);
    ioe.printStackTrace(System.err);
    RemoteDataServer:
    public RemoteDataServer() {
    try {
    ...many different servers started here...
    ServerSocket PersonReadSocket = new ServerSocket(personReadPort);
    PersonReadListener prl = new PersonReadListener(PersonReadSocket);
    prl.start();
    catch (IOException ioe) {
    COMMENT: This message is never printed.
    System.err.println(ioe);
    ioe.printStackTrace(System.err);
    COMMENT: PersonReadListener is an inner class:
    class PersonReadListener extends java.lang.Thread {
    private Thread BaseThread;
    private ServerSocket theSocket;
    /** Creates an object to listen for PersonRead requests
    * @param ss The server socket to listen with
    public PersonReadListener(ServerSocket ss) {
    theSocket = ss;
    /** Initializes the thread to listen for PersonRead requests
    public void start() {
    BaseThread = new Thread(this);
    BaseThread.start();
    /** The code for the server to listen for PersonRead requests
    public void run() {
    while(true) {
    try {
    COMMENT: This code doesn't have access to System.err
    COMMENT: so a file is created to print debugging output
    PrintWriter debug = new PrintWriter(new FileWriter("person.debug"));
    COMMENT: The next line IS printed, so the server gets
    COMMENT: this far.
    debug.println("Waiting for connection for person's name");
    debug.close();
    PersonReadClientConnection someone =
    new PersonReadClientConnection(theSocket.accept());
    COMMENT: If the previous "debug.close" line is
    COMMENT: commented out and the next two lines are
    COMMENT: uncommented, the next line is NOT
    COMMENT: printed, so apparently the accept nevers
    COMMENT: happens! Why does the accept fail, but
    COMMENT: the client's socket creation succeed?
    // debug.println("Accepted a connection");
    // debug.close();
    someone.start();
    catch (IOException ioe) {
    COMMENT: These lines are NOT printed
    System.err.println(ioe);
    ioe.printStackTrace(System.err);

  • Re: Connection Failure: ReadFile on fd=1231 failed with err=64  + JVM_recv in socket input stream read

    Jon,
    I believe that this error is similar to a "connection reset by peer". It is
    a Window specific error. I believe it indicates that something has happened
    on the other end of the socket such that the socket has gone bad.
    I think that this should only occur when people reset their connection
    before the reply is sent. I don't believe that it is indicative of any
    serious problem other than this communication failure caused by the client.
    I've opened an issue to catch and squelch these spurious exceptions rather
    than logging them. For now I think it is safe to ignore them.
    Regards,
    Adam
    "Jon Mountjoy" <[email protected]> wrote in message
    news:[email protected]...
    Hi Guys,
    Using weblogic 5.1 (downloaded pretty soon after announcement) on windows
    2000 (yes I know not certified there yet) and using jdk1.2.2-001.
    I have a pretty standard setup - a connection pool (5) to a sqlserver
    (remote) machine.
    A pretty standard multithreaded servlet - grabs a connection, does aselect,
    calls dbkona to dump output, releases connection.
    It runs fine - browser returns result. When I push 'reload' on browser,say
    10 times very quickly, I get the following errors. It is sometimes a
    combination of these:
    1- Mon May 08 13:34:41 GMT+00:00 2000:<E> <HTTP> Connection failure
    java.net.SocketException: ReadFile on fd=1912 failed with err=64
    at weblogic.socket.NTSocketMuxer.initiateIO(Native Method)
    at weblogic.socket.NTSocketMuxer.read(NTSocketMuxer.java, Compiled
    Code)
    2- Mon May 08 13:40:42 GMT+00:00 2000:<D> <ListenThread> Problem
    accepting connecti on java.net.SocketException: Connection reset by peer:
    JVM_recv in socket input stream read
    Now I can get rid of (1) by switching off native IO!! This also stoppedIO
    exceptions that were being raised by the servlet when it tried to outputto
    the output stream. (2) persists.
    I have changed nothing else in the properties.
    (1) sounds like I may need to up the number of file descriptors open?
    (2) I don't know. Is my server too loaded? I am running on a 600Mhzusing
    64Mb heap for the server with 300Mb swap available...
    Regards,
    Jon
    More substantial excerpts:
    Mon May 08 13:40:42 GMT+00:00 2000:<D> <ListenThread> Problem accepting
    connection
    java.net.SocketException: Connection reset by peer: JVM_recv in socketinput
    stream read
    at java.net.SocketInputStream.socketRead(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java, Compiled Code)
    at weblogic.socket.ResettableSocket.getPrefix(ResettableSocket.java,
    Compiled Code)
    at weblogic.socket.JVMSocketT3.claimSocket(JVMSocketT3.java, CompiledCode)
    at weblogic.socket.JVMSocketT3.claimSocket(JVMSocketT3.java, CompiledCode)
    at weblogic.socket.JVMSocketManager.accept(JVMSocketManager.java,Compiled
    Code)
    at
    weblogic.t3.srvr.ListenThread$RJVMListenRequest.execute(ListenThread.java,
    Compiled Code)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)
    Mon May 08 13:35:31 GMT+00:00 2000:<E> <HTTP> Connection failure
    java.net.SocketException: ReadFile on fd=1980 failed with err=64
    at weblogic.socket.NTSocketMuxer.initiateIO(Native Method)
    at weblogic.socket.NTSocketMuxer.read(NTSocketMuxer.java, Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.requeue(MuxableSocketHTTP.java,
    Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java,
    Compiled Code)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)
    Mon May 08 13:35:31 GMT+00:00 2000:<E> <HTTP> Connection failure
    java.net.SocketException: ReadFile on fd=1760 failed with err=64
    at weblogic.socket.NTSocketMuxer.initiateIO(Native Method)
    at weblogic.socket.NTSocketMuxer.read(NTSocketMuxer.java, Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.requeue(MuxableSocketHTTP.java,
    Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java,
    Compiled Code)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)
    Mon May 08 13:35:31 GMT+00:00 2000:<E> <HTTP> Connection failure
    java.net.SocketException: ReadFile on fd=1908 failed with err=64
    at weblogic.socket.NTSocketMuxer.initiateIO(Native Method)
    at weblogic.socket.NTSocketMuxer.read(NTSocketMuxer.java, Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.requeue(MuxableSocketHTTP.java,
    Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java,
    Compiled Code)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)

    We are seeing the same error since switching to sp11 (we had been using
    sp10). Haven't seen it in Solaris though. What is causing it?
    Wed May 08 12:01:48 EDT 2002:<E> <HTTP> Connection failure
    java.net.SocketException: ReadFile on fd=3640 failed with err=64
    at weblogic.socket.NTSocketMuxer.initiateIO(Native Method)
    at weblogic.socket.NTSocketMuxer.read(NTSocketMuxer.java:259)
    at weblogic.socket.MuxableSocketHTTP.requeue(MuxableSocketHTTP.java:178)
    at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:280)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:129)
    "John Slaman" <[email protected]> wrote in message
    news:[email protected]..
    >
    I'm getting a error as follows:
    Mon Apr 22 19:04:10 EDT 2002:<E> <HTTP> Connection failure
    java.net.SocketException: ReadFile on fd=2368 failed with err=64
    at weblogic.socket.NTSocketMuxer.initiateIO(Native Method)
    at weblogic.socket.NTSocketMuxer.read(NTSocketMuxer.java, Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.requeue(MuxableSocketHTTP.java,Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java,Compiled Code)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)
    I have no idea as to the cause. It's been posted in the archives before -but with
    no particular solution.
    I'm using WLS 5.1 SP11, JDK 1.2.2_007. Win2000.
    Does anybody know the cause/solution?
    Thanks.
    "Jon Mountjoy" <[email protected]> wrote:
    Hi,
    I have noticed that applying the service pack helps things quite a bit.
    I no longer get NT muxer errors etc etc. just the "connection reset by
    peer"
    every now and again.
    As I am repeatedly hitting the server from one browser, your 'connection
    going bad' scenario probably
    applies quite well.
    (btw. before the SP, the errors seemed to crop up more just before/during
    a
    GC.)
    Jon

  • Connection Failure: ReadFile on fd=1231 failed with err=64  + JVM_recv in socket input stream read

    Hi Guys,
    Using weblogic 5.1 (downloaded pretty soon after announcement) on windows
    2000 (yes I know not certified there yet) and using jdk1.2.2-001.
    I have a pretty standard setup - a connection pool (5) to a sqlserver
    (remote) machine.
    A pretty standard multithreaded servlet - grabs a connection, does a select,
    calls dbkona to dump output, releases connection.
    It runs fine - browser returns result. When I push 'reload' on browser, say
    10 times very quickly, I get the following errors. It is sometimes a
    combination of these:
    1- Mon May 08 13:34:41 GMT+00:00 2000:<E> <HTTP> Connection failure
    java.net.SocketException: ReadFile on fd=1912 failed with err=64
    at weblogic.socket.NTSocketMuxer.initiateIO(Native Method)
    at weblogic.socket.NTSocketMuxer.read(NTSocketMuxer.java, Compiled
    Code)
    2- Mon May 08 13:40:42 GMT+00:00 2000:<D> <ListenThread> Problem
    accepting connecti on java.net.SocketException: Connection reset by peer:
    JVM_recv in socket input stream read
    Now I can get rid of (1) by switching off native IO!! This also stopped IO
    exceptions that were being raised by the servlet when it tried to output to
    the output stream. (2) persists.
    I have changed nothing else in the properties.
    (1) sounds like I may need to up the number of file descriptors open?
    (2) I don't know. Is my server too loaded? I am running on a 600Mhz using
    64Mb heap for the server with 300Mb swap available...
    Regards,
    Jon
    More substantial excerpts:
    Mon May 08 13:40:42 GMT+00:00 2000:<D> <ListenThread> Problem accepting
    connection
    java.net.SocketException: Connection reset by peer: JVM_recv in socket input
    stream read
    at java.net.SocketInputStream.socketRead(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java, Compiled Code)
    at weblogic.socket.ResettableSocket.getPrefix(ResettableSocket.java,
    Compiled Code)
    at weblogic.socket.JVMSocketT3.claimSocket(JVMSocketT3.java, Compiled Code)
    at weblogic.socket.JVMSocketT3.claimSocket(JVMSocketT3.java, Compiled Code)
    at weblogic.socket.JVMSocketManager.accept(JVMSocketManager.java, Compiled
    Code)
    at
    weblogic.t3.srvr.ListenThread$RJVMListenRequest.execute(ListenThread.java,
    Compiled Code)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)
    Mon May 08 13:35:31 GMT+00:00 2000:<E> <HTTP> Connection failure
    java.net.SocketException: ReadFile on fd=1980 failed with err=64
    at weblogic.socket.NTSocketMuxer.initiateIO(Native Method)
    at weblogic.socket.NTSocketMuxer.read(NTSocketMuxer.java, Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.requeue(MuxableSocketHTTP.java,
    Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java,
    Compiled Code)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)
    Mon May 08 13:35:31 GMT+00:00 2000:<E> <HTTP> Connection failure
    java.net.SocketException: ReadFile on fd=1760 failed with err=64
    at weblogic.socket.NTSocketMuxer.initiateIO(Native Method)
    at weblogic.socket.NTSocketMuxer.read(NTSocketMuxer.java, Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.requeue(MuxableSocketHTTP.java,
    Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java,
    Compiled Code)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)
    Mon May 08 13:35:31 GMT+00:00 2000:<E> <HTTP> Connection failure
    java.net.SocketException: ReadFile on fd=1908 failed with err=64
    at weblogic.socket.NTSocketMuxer.initiateIO(Native Method)
    at weblogic.socket.NTSocketMuxer.read(NTSocketMuxer.java, Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.requeue(MuxableSocketHTTP.java,
    Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java,
    Compiled Code)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)

    I have exactly the same problem running on Windows NT 4.0 (SP4) Weblogic 5.1 and
    JDK1.2.2-001.
    java.net.SocketException: ReadFile on fd=1048 failed with err=64
    at weblogic.socket.NTSocketMuxer.initiateIO(Native Method)
    at weblogic.socket.NTSocketMuxer.read(NTSocketMuxer.java, Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.requeue(MuxableSocketHTTP.java, Compiled
    Code)
    at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java, Compiled
    Code)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)
    Jon Mountjoy wrote:
    Hi Guys,
    Using weblogic 5.1 (downloaded pretty soon after announcement) on windows
    2000 (yes I know not certified there yet) and using jdk1.2.2-001.
    I have a pretty standard setup - a connection pool (5) to a sqlserver
    (remote) machine.
    A pretty standard multithreaded servlet - grabs a connection, does a select,
    calls dbkona to dump output, releases connection.
    It runs fine - browser returns result. When I push 'reload' on browser, say
    10 times very quickly, I get the following errors. It is sometimes a
    combination of these:
    1- Mon May 08 13:34:41 GMT+00:00 2000:<E> <HTTP> Connection failure
    java.net.SocketException: ReadFile on fd=1912 failed with err=64
    at weblogic.socket.NTSocketMuxer.initiateIO(Native Method)
    at weblogic.socket.NTSocketMuxer.read(NTSocketMuxer.java, Compiled
    Code)
    2- Mon May 08 13:40:42 GMT+00:00 2000:<D> <ListenThread> Problem
    accepting connecti on java.net.SocketException: Connection reset by peer:
    JVM_recv in socket input stream read
    Now I can get rid of (1) by switching off native IO!! This also stopped IO
    exceptions that were being raised by the servlet when it tried to output to
    the output stream. (2) persists.
    I have changed nothing else in the properties.
    (1) sounds like I may need to up the number of file descriptors open?
    (2) I don't know. Is my server too loaded? I am running on a 600Mhz using
    64Mb heap for the server with 300Mb swap available...
    Regards,
    Jon
    More substantial excerpts:
    Mon May 08 13:40:42 GMT+00:00 2000:<D> <ListenThread> Problem accepting
    connection
    java.net.SocketException: Connection reset by peer: JVM_recv in socket input
    stream read
    at java.net.SocketInputStream.socketRead(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java, Compiled Code)
    at weblogic.socket.ResettableSocket.getPrefix(ResettableSocket.java,
    Compiled Code)
    at weblogic.socket.JVMSocketT3.claimSocket(JVMSocketT3.java, Compiled Code)
    at weblogic.socket.JVMSocketT3.claimSocket(JVMSocketT3.java, Compiled Code)
    at weblogic.socket.JVMSocketManager.accept(JVMSocketManager.java, Compiled
    Code)
    at
    weblogic.t3.srvr.ListenThread$RJVMListenRequest.execute(ListenThread.java,
    Compiled Code)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)
    Mon May 08 13:35:31 GMT+00:00 2000:<E> <HTTP> Connection failure
    java.net.SocketException: ReadFile on fd=1980 failed with err=64
    at weblogic.socket.NTSocketMuxer.initiateIO(Native Method)
    at weblogic.socket.NTSocketMuxer.read(NTSocketMuxer.java, Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.requeue(MuxableSocketHTTP.java,
    Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java,
    Compiled Code)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)
    Mon May 08 13:35:31 GMT+00:00 2000:<E> <HTTP> Connection failure
    java.net.SocketException: ReadFile on fd=1760 failed with err=64
    at weblogic.socket.NTSocketMuxer.initiateIO(Native Method)
    at weblogic.socket.NTSocketMuxer.read(NTSocketMuxer.java, Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.requeue(MuxableSocketHTTP.java,
    Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java,
    Compiled Code)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)
    Mon May 08 13:35:31 GMT+00:00 2000:<E> <HTTP> Connection failure
    java.net.SocketException: ReadFile on fd=1908 failed with err=64
    at weblogic.socket.NTSocketMuxer.initiateIO(Native Method)
    at weblogic.socket.NTSocketMuxer.read(NTSocketMuxer.java, Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.requeue(MuxableSocketHTTP.java,
    Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java,
    Compiled Code)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)

  • JVM_recv in socket input stream read (code=10004)

    Whilst trying to get a file listing from an FTP server (by sending FTP commands directly to the server according to RFC959)
    I got..
    JVM_recv in socket input stream read (code=10004)
    What does this mean? Any idea why it is caused, the socket should be open as far as I am concerned - could something external be affecting it?

    Platform/JVM? I'd guess Windows - 10004 looks like WSAEINTR, from WinSock. (Here's some specifics that may help:
    http://support.ipswitch.com/kb/WSK-19980714-EM08.htm )

  • Server Socket does not read data input stream

    Hi all,
    I am very newbie to Java Network programming with sockets and multi-threading.
    But I am obliged to develop a chat system written in Applets which can be placed on the website and used by visitors who come to my website.
    In order to understand this, I have tested a basic web chat program I downloaded from the Internet which use sockets and multi-threadings. The program work fine, no bugs at all at both compilation and run time. I noticed that all three streams for Client side (i.e. first one is input stream used receiving data from User; the second one is socket input stream used for receiving data from Server socket, and the third is socket output stream used for writing data to server socket) were established. And the same, two socket streams (input & output) for Server side were also connected when running program giving right port number and IP address of the server.
    The problem is both server and client sockets do not read data using the following stream classes:
    1. DataStreamInput: I use input.readUTF() method
    2. or BufferedReader: I use input.readLine() method
    The example of the codes are below:
    private BufferedReader input = null;
    private PrintWriter output = null;
    private Socket socket = null;
    public void open() throws IOException
    {  input = new BufferedReader(new
    InputStreamReader(socket.getInputStream()));
    System.out.println("Server socket input stream was created, and");
    output = new PrintWriter(socket.getOutputStream());
    System.out.println("Server socket output stream was created");
    public void run()
    {  System.out.println("Server Thread " + clientPort + " running.");
    while (true)
    {  try
    System.out.println("Server is reading data from Client, wait...");
    String fromClient = input.readLine();
    System.out.println("Server received a message on " + clientPort + ".");
    catch(IOException ioe)
    {  System.out.println(clientPort + " ERROR reading: " + ioe.getMessage());
    server.remove(clientPort);
    stop();
    The problem is at the line: String fromClient = input.readLine(); in the run() method? What is wrong with the codes above?
    Note: I also try to use original codes which use readUTF() method in DataStreamInput class instead using readLine() in BufferedReader. Both methods dont read data from inputstream socket?
    I very appreciate any help/advice from experienced developers.
    Best regards

    Hi,
    Yes. The readLine() method hangs! After the test, the execuation of the program is stopped at the line of readLine() method; it does not pass it?
    There is no problem with writing to Server socket. After the test, the program pass through flush() method. Here is the code for writing to sever socket within ChatClient (client side socket) class:
    private BufferedReader input = null;
    private PrintWriter           output = null;
    public ChatClient(String serverName, int serverPort)
    {  System.out.println("Establishing connection. Please wait ...");
    try
    {  socket = new Socket(serverName, serverPort);
    System.out.println("Connected: " + socket);
    start();
    catch(UnknownHostException uhe)
    {  System.out.println("Host unknown: " + uhe.getMessage()); }
    catch(IOException ioe)
    {  System.out.println("Unexpected exception: " + ioe.getMessage()); }
    public void start() throws IOException
    {  input   = new BufferedReader (new
                             InputStreamReader(System.in));
    System.out.println("Client User input stream was created,");
    output = new PrintWriter(socket.getOutputStream());
    System.out.println("Client Socket output stream was established, and");
    if (thread == null)
    {  client = new ChatClientThread(this, socket);
    thread = new Thread(this);
    thread.start();
    public void run()
         while (thread != null) {
         String fromUser;
              try{
                   while((fromUser = input.readLine())!= null)
                   System.out.println("Client wasreading a data from User, and");
    output.println(fromUser);
         output.flush();
         System.out.println("Client has written a data to Server");
    catch(IOException ioe)
    {  System.out.println("Sending to server error: " + ioe.getMessage());
    stop();
    etc.
    Here is a piece of codes for reading data from the Client Socket in the ChatServer Class (Server Side socket):
    public void run()
    {  System.out.println("Server Thread " + clientPort + " running.");
    while (true)
    {  try
    {  //server.handle(clientPort, input.readLine());
    System.out.println("Server is reading data from Client, wait...");
    String fromUser = input.readLine();
    //while((fromUser = input.readLine()) != null)
         System.out.println("Server received a message on " + clientPort + ".");
    catch(IOException ioe)
    {  System.out.println(clientPort + " ERROR reading: " + ioe.getMessage());
    server.remove(clientPort);
    stop();
    etc. Please advice why the readLine() method hangs; does not read data from the input stream received from the CLIENT?

  • SocketException during reads - JVM_recv in socket input stream read

    I am getting a SocketException when a Java applet talks to our
    WebLogic 7.0 server. The catch is that it only occurs at one site
    (that has very high T1 utilization, although latency is only ~60 ms)
    Our setup is such that the calls hit an Alteon load balancer, which
    then sends the request out to one of 4 IIS clustered servers, where it
    then is sent to one of 2 WL clustered servers. I figured latency
    would be the cause, but on IIS and on WL, the timeouts are set to
    several hundred seconds, so I am not quite seeing where the connection
    is being reset. To be honest, I really don't know if it is WL that is
    killing the connection, as nothing abnormal shows up in the WL log. I
    have seen similar problems in this group, though, although the stack
    traces never follow the same path mine does. I do have the following
    call stack from the Java plug-in console, though. Any ideas would be
    greatly appreciated.
    java.net.SocketException: Connection reset by peer: JVM_recv in socket
    input stream read
         at java.net.SocketInputStream.socketRead0(Native Method)
         at java.net.SocketInputStream.read(Unknown Source)
         at java.io.BufferedInputStream.fill(Unknown Source)
         at java.io.BufferedInputStream.read1(Unknown Source)
         at java.io.BufferedInputStream.read(Unknown Source)
         at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
         at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
         at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
         at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown
    Source)
         at sun.plugin.net.protocol.http.HttpURLConnection.getInputStream(Unknown
    Source)
         at sun.net.www.protocol.http.HttpURLConnection.getHeaderFields(Unknown
    Source)
         at sun.plugin.net.protocol.http.HttpURLConnection.checkCookieHeader(Unknown
    Source)
         at sun.plugin.net.protocol.http.HttpURLConnection.getInputStream(Unknown
    Source)
         at org.xxxx.abstracts.Controller.sendRequest(Controller.java:39)
         at org.xxxx.data.DataMediator.getDataNode(DataMediator.java:46)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Also, here is my code, although I can't see anything on the client
    side that seems off:
    public Object sendRequest( Object request, URL receiver ) throws
    Exception{
    Object response = null;
    URLConnection con = null;
    ObjectOutputStream out = null;
    ObjectInputStream in = null;
    try {
    con = receiver.openConnection();
    con.setDoInput(true);
    con.setDoOutput(true);
    con.setUseCaches(false);
    con.setDefaultUseCaches(false);
    con.setAllowUserInteraction(false);
    out = new ObjectOutputStream(con.getOutputStream());
    out.writeObject(request);
    out.flush();
    out.close();
    in = new ObjectInputStream(con.getInputStream());
    response = in.readObject();
    in.close();
    } catch (ClassCastException e) {
    if( out != null ){
    out.close();
    if( in != null ){
    in.close();
    } catch (Exception e) {
    if( out != null ){
    out.close();
    if( in != null ){
    in.close();
    throw e;
    return response;

    There is a known bug on earlier 1.3.1 releases with sockets on Windows 2k
    and XP. I don't remember all the details.
    Peace,
    Cameron Purdy
    Tangosol, Inc.
    http://www.tangosol.com/coherence.jsp
    Tangosol Coherence: Clustered Replicated Cache for Weblogic
    "Keith Patrick" <[email protected]> wrote in message
    news:[email protected]...
    I'm getting the exception on the client, which is an XP machine, while
    the server is Win2K. I can't recall which, but either the applet or
    the server runs 1.3x while the other runs 1.4. I discounted that
    factor, though, as the problem only occurs on one site, which on all
    others it works fine.
    "Cameron Purdy" <[email protected]> wrote in message
    news:<[email protected]>...
    Exception is in the applet or on the server?
    Would one of those by any chance be running on W2K with JDK 131_01 orolder?
    >>
    Peace,
    Cameron Purdy
    Tangosol, Inc.
    http://www.tangosol.com/coherence.jsp
    Tangosol Coherence: Clustered Replicated Cache for Weblogic
    "Keith Patrick" <[email protected]> wrote in message
    news:[email protected]...
    I am getting a SocketException when a Java applet talks to our
    WebLogic 7.0 server. The catch is that it only occurs at one site
    (that has very high T1 utilization, although latency is only ~60 ms)
    Our setup is such that the calls hit an Alteon load balancer, which
    then sends the request out to one of 4 IIS clustered servers, where it
    then is sent to one of 2 WL clustered servers. I figured latency
    would be the cause, but on IIS and on WL, the timeouts are set to
    several hundred seconds, so I am not quite seeing where the connection
    is being reset. To be honest, I really don't know if it is WL that is
    killing the connection, as nothing abnormal shows up in the WL log. I
    have seen similar problems in this group, though, although the stack
    traces never follow the same path mine does. I do have the following
    call stack from the Java plug-in console, though. Any ideas would be
    greatly appreciated.
    java.net.SocketException: Connection reset by peer: JVM_recv in socket
    input stream read
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(Unknown Source)
    at java.io.BufferedInputStream.fill(Unknown Source)
    at java.io.BufferedInputStream.read1(Unknown Source)
    at java.io.BufferedInputStream.read(Unknown Source)
    at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
    at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
    at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown
    Source)
    at
    sun.plugin.net.protocol.http.HttpURLConnection.getInputStream(Unknown
    Source)
    at sun.net.www.protocol.http.HttpURLConnection.getHeaderFields(Unknown
    Source)
    atsun.plugin.net.protocol.http.HttpURLConnection.checkCookieHeader(Unknown
    Source)
    atsun.plugin.net.protocol.http.HttpURLConnection.getInputStream(Unknown
    Source)
    at org.xxxx.abstracts.Controller.sendRequest(Controller.java:39)
    at org.xxxx.data.DataMediator.getDataNode(DataMediator.java:46)
    at sun.applet.AppletPanel.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Also, here is my code, although I can't see anything on the client
    side that seems off:
    public Object sendRequest( Object request, URL receiver ) throws
    Exception{
    Object response = null;
    URLConnection con = null;
    ObjectOutputStream out = null;
    ObjectInputStream in = null;
    try {
    con = receiver.openConnection();
    con.setDoInput(true);
    con.setDoOutput(true);
    con.setUseCaches(false);
    con.setDefaultUseCaches(false);
    con.setAllowUserInteraction(false);
    out = new ObjectOutputStream(con.getOutputStream());
    out.writeObject(request);
    out.flush();
    out.close();
    in = new ObjectInputStream(con.getInputStream());
    response = in.readObject();
    in.close();
    } catch (ClassCastException e) {
    if( out != null ){
    out.close();
    if( in != null ){
    in.close();
    } catch (Exception e) {
    if( out != null ){
    out.close();
    if( in != null ){
    in.close();
    throw e;
    return response;

  • JDBC Connection reset by peer: JVM_recv in socket input stream read

    Hey Guys,
    Has anyone seen this issue? We get this error in our Weblogic app logs at times and no one is able to login to our application. Our database server and SQL server seem fine at a high level. Any ideas what is causing this?
    com.s1.arch.persistence.exception.PersistenceException weblogic.jdbc.mssqlserver4.TdsException: I/O exception while talking to the server, java.net.SocketException: Connection reset by peer: JVM_recv in socket input stream read
    Thanks

    please make sure that there is no Firewall between your servers and DB server. this message usually happen when there is a fire wall between the servers. if yes please make sure that the connection time on fire wall is longer than the time needed to complete an operation another thing that you need to check if you have a fire wall which is to make sure that Oracle DBMS return the request to the same port that it is listening to (1521 default).

Maybe you are looking for

  • I can't install Adobe Scout

    I just downloaded CC to try Adobe Scout, but I can't install it. At 51% the installation fails. The error says: <PRE>Exit Code: 7 Please see specific errors below for troubleshooting. For example,  ERROR: -------------------------------------- Summar

  • Inherit filter choice from the above folder..

    I have made a document library with 4 content type folders that a documents in it, I have made a column named countries when I filter the countries to Belgium i espect to only see the documents of Belgium that folder but when I open the folder I see

  • Supplier Accounts in AP

    Hi, This is regarding an 11i Implementation. We have set up a single default Charge/Expense Account. And also a single Payables Liability account for all AP Suppliers. So when invoices are created, Payables Liability is booked to a single account (sa

  • FAGLL03 - profit center wise

    Hi, We want to run the report FAGLL03 Profit center wise (using dynamic selection). But, Company code is being inevitable to run this report. We cannot restrict profit center for a single company code. And we have configuration issues in CO, and cann

  • Data Guard - chapter 2 - Failover & roles

    Okay, with some help from everyone here I have my test boxes in a primary & physical standby setup and everything is running fine. My next step was to do a test of failover which was the entire reason for this. If we lose the primary due to a hardwar