Probably a silly question


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Probably a silly question

  1. #1
    GJ Guest

    Probably a silly question


    In java how do I tell if a socket was disconnected?
    In C++/C# I can just poll the socket to get its status...

    But how do I do that in Java? I thought the getInputStream would throw an
    exception but it doesn't. and it just shows 0 bytes available. But if the
    client closes, how is the server supposed to know? Seems like a silly question....
    probably trivial, but would make my life easier.

  2. #2
    flairn Guest

    Re: Probably a silly question


    "GJ" <star_screamer@hotmail.com> wrote:
    >
    >In java how do I tell if a socket was disconnected?
    >In C++/C# I can just poll the socket to get its status...
    >
    >But how do I do that in Java? I thought the getInputStream would throw an
    >exception but it doesn't. and it just shows 0 bytes available. But if the
    >client closes, how is the server supposed to know? Seems like a silly question....
    >probably trivial, but would make my life easier.




    "isClosed"
    public boolean isClosed()
    Returns the closed state of the socket

    Returns:
    true if the socket has been closed
    Since:
    1.4



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center