Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2012
    Posts
    6
    Rep Power
    0

    Question HELP: Socket input stream that should block indefinitely doesn't

    I have a terminal emulation program (a TN5250 implementation). It seems to work consistently for most installations, but for some users at one installation, a read on the input stream of the socket (which should, in theory, block indefinitely while waiting for incoming data) will, seemingly at random, return a -1 (EOF), mere milliseconds after a successful read. And I've been completely unable to reproduce the problem elsewhere: either it works, or it throws an exception, but it doesn't EOF. My understanding is that it shouldn't EOF unless it has somehow been set to not block indefinitely.

    Anybody have any idea why an input stream on a socket would EOF instead of blocking or throwing an exception?

    The socket gets created thusly:

    Java Code:
        public Socket createSocket(boolean secure, String address, int port)
          throws IOException {
          return (secure) ? SSLClass.getSocket(address, port) :
            new Socket(address, port);
        }
    (where SSLClass is an internal class that sets up SSL, gets an SSL context, gets its socket factory, and returns a socket obtained from that factory)

    and then the stream is obtained with
    Java Code:
                is = socket.getInputStream();
    and read with
    Java Code:
                    int incr = is.read(bytes, length, amtToRead);

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is online now Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,300
    Rep Power
    20

    Default Re: HELP: Socket input stream that should block indefinitely doesn't

    Moved from Advanced Java

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    Join Date
    Dec 2012
    Posts
    6
    Rep Power
    0

    Default Re: HELP: Socket input stream that should block indefinitely doesn't

    Last night, on my way home, I had another idea: maybe the fact that I ran my tests in Secured (SSL) Telnet mode might have had something to do with it. So I just got finished running a battery of tests in unsecured mode (not that I'm actually aware of the users in question running unsecured).

    No change.

    If I kill the connection from the host side, it throws an exception.

    If I physically disconnect the Ethernet cable, it just sits there, for minutes at a time, with the read on the socket stream continuing to block. Eventually, if I plug the cable back in, it continues to sit there, eventually throwing a "connection reset" exception.

    Nothing I've been able to do has caused the socket input stream to EOF.

    Anybody have any idea what could cause a socket input stream to EOF?

  4. #4
    Join Date
    Dec 2012
    Posts
    6
    Rep Power
    0

    Default Re: HELP: Socket input stream that should block indefinitely doesn't

    Further information: it seems to be happening in connection with some sort of virtualization. The customer hasn't yet answered my question about what kind of virtualization, or what they're doing with it; all I know is that they say it only happens on "Virtual Machines" (their capitalization).

Similar Threads

  1. Help with input stream
    By Slice28 in forum New To Java
    Replies: 1
    Last Post: 03-14-2012, 09:45 PM
  2. Should this input stream be closed?
    By barock in forum Advanced Java
    Replies: 8
    Last Post: 06-10-2011, 07:11 PM
  3. Readline from an input stream and nothing more.
    By couling in forum Advanced Java
    Replies: 19
    Last Post: 05-27-2011, 09:20 PM
  4. array input block
    By waklo99 in forum New To Java
    Replies: 11
    Last Post: 09-20-2010, 03:04 AM
  5. Input stream error
    By Johnny68 in forum New To Java
    Replies: 10
    Last Post: 08-05-2010, 06:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •