DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  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



Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links