Thursday, June 28, 2001 01:15 AM
In my server socket program there is while loop to read the data from client. If client socket is closed before sending any data because of n/w problem. How to come out of that loop.
Is there any way to check that other end socket is closed.
code is as follows.
soc = sersoc.accept();
InputStream is = soc.getInputStream();
bis = new BufferedInputStream(is);
while(len == 0)
len = bis.available(); /*how to come out from
if client socket closed before
sending any data */
} // End of while(len == 0)
byte b = new byte[len];
int l = bis.read(b, 0, b.length);
String s = new String(b);
System.out.println("Message : " + s);
System.out.println("Server is not connected");
Re: Identifying socket disconnection.
Thursday, June 28, 2001 10:38 AM