Help with socket problem

Discussion in 'Java' started by Petterson Mikael, Aug 20, 2003.

  1. Hi,

    I have coded a package that sends an sms via a gateway.
    Here is what is happening:

    * I create a singleton of my SMSModule.
    * I create an sms object.
    * I put the object in a Queue.
    * I start a new Thread in my sms module that reads sms from queue.
    * I connect to sms gateway.
    * I send the sms.
    * I disconnect from socket! This is where things go wrong and I get the
    following error (see below).

    I have a zip file with the code so if you have time to take a look at it
    I would appreciate it.

    I am also interested in looking at other examples of code just so I can
    figure out what is going wrong.
    I have been stuck on this matter for a while so your help will be
    greatly appreciated.

    //Mikael


    GOT: !LogoffConf: mSIP
    Kommando var: !LogoffConf
    CoolFlix log: MSIPProtocolHandler;setLoggedin(false) We got LogOffConf
    Waiting ......for thread to die
    java.net.SocketException: Socket operation on nonsocket: JVM_recv in
    socket input stream read at
    java.net.SocketInputStream.socketRead0(Native Method) at
    java.net.SocketInputStream.read(SocketInputStream.java:116) at
    sun.nio.cs.StreamDecoder$CharsetSD.readBytes(StreamDecoder.java:405)
    Petterson Mikael, Aug 20, 2003
    #1
    1. Advertising

  2. > Hi,
    >
    > I have coded a package that sends an sms via a gateway.
    > * I disconnect from socket! This is where things go wrong and I get the
    > following error (see below).

    ....
    > java.net.SocketException: Socket operation on nonsocket: JVM_recv in
    > socket input stream read at
    > java.net.SocketInputStream.socketRead0(Native Method) at
    > java.net.SocketInputStream.read(SocketInputStream.java:116) at
    > sun.nio.cs.StreamDecoder$CharsetSD.readBytes(StreamDecoder.java:405)


    I imagine you get this error on the server. It's because the server is
    blocked on an InputStream read() and your client closes the connection. Your
    client needs to send some sort of close message to the server and then have
    the server close the socket.

    --
    Jordan Zimmerman
    http://www.jordanzimmerman.com
    Jordan Zimmerman, Aug 20, 2003
    #2
    1. Advertising

  3. Petterson Mikael

    EJP Guest

    Jordan Zimmerman wrote:
    >
    > > Hi,
    > >
    > > I have coded a package that sends an sms via a gateway.
    > > * I disconnect from socket! This is where things go wrong and I get the
    > > following error (see below).

    > ...
    > > java.net.SocketException: Socket operation on nonsocket: JVM_recv in
    > > socket input stream read at
    > > java.net.SocketInputStream.socketRead0(Native Method) at
    > > java.net.SocketInputStream.read(SocketInputStream.java:116) at
    > > sun.nio.cs.StreamDecoder$CharsetSD.readBytes(StreamDecoder.java:405)

    >
    > I imagine you get this error on the server. It's because the server is
    > blocked on an InputStream read() and your client closes the connection. Your
    > client needs to send some sort of close message to the server and then have
    > the server close the socket.


    No. This is not the problem. The reader would get an EOFException or a
    -1 return value if it read and the other end had closed. This is 'socket
    operation on nonsocket' which on the face of it is a JCL or JVM bug.
    I've seen this discussed before: have a look on the Bug Parade.
    EJP, Aug 21, 2003
    #3
  4. Hi,

    Thanks for your reply! I greatly appreciate you taking your valuble time
    to help out.

    I have looked into the "bug parade" at "Sun" and did not find a problem
    with the jvm. When I searched the Web, before asking the question, I
    also found comments and questions about "Socket operation on a
    nonsocket". However no solution to the problem.

    Could it be that it is a os dependent problem?

    I code/execute/test on Windows Me with Jdk1.4.1 At the office I use
    Solaris but we are behind a firewall and it is not possible to connect
    to the external sms gateway to send the sms.

    Anyone out there with Solaris/Linux/Windows 2000 that want to try my
    code out and see if it could send the sms? I know this sounds odd but
    that is my only option for now. I need to find out if there is a problem
    with the JDK version on Windows Me.


    //Mikael
    Petterson Mikael, Aug 22, 2003
    #4
  5. Petterson Mikael

    EJP Guest

    You'll get a reset error if you are *writing* to a socket closed by the
    other end.

    Jordan Zimmerman wrote:
    >
    > "EJP" <> wrote in message
    > news:...
    > >
    > >
    > > No. This is not the problem. The reader would get an EOFException or a
    > > -1 return value if it read and the other end had closed. This is 'socket
    > > operation on nonsocket' which on the face of it is a JCL or JVM bug.
    > > I've seen this discussed before: have a look on the Bug Parade.

    >
    > That's what's supposed to happen. But, I'm always getting various exceptions
    > when a client closes unexpectedly. There are 5-10 different messages in the
    > IOException.
    >
    > --
    > Jordan Zimmerman
    > http://www.jordanzimmerman.com
    >
    > "EJP" <> wrote in message
    > news:...
    EJP, Aug 22, 2003
    #5
  6. Jordan Zimmerman, Aug 22, 2003
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Laszlo Nagy
    Replies:
    1
    Views:
    4,771
    Mark Wooding
    Jan 27, 2009
  2. Jean-Paul Calderone
    Replies:
    0
    Views:
    952
    Jean-Paul Calderone
    Jan 27, 2009
  3. Laszlo Nagy
    Replies:
    0
    Views:
    532
    Laszlo Nagy
    Feb 1, 2009
  4. Steve Holden
    Replies:
    0
    Views:
    650
    Steve Holden
    Feb 1, 2009
  5. Steve Holden
    Replies:
    1
    Views:
    704
Loading...

Share This Page