hi
the code i posted is not actual code
actually ss.close is part of a function which i am calling on certain
condition
as far as ss.accpet call it is working perfectly
i am using jdk1.2.2 on windows NT and jdk1.2.2RC4 on linux
ashish
----- Original Message -----
From: "Albert Y. C. Lai" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, May 14, 2000 8:39 PM
Subject: Re: How to close ServerSocket
> "Ashish" <[EMAIL PROTECTED]> writes:
>
> > how to close server socket without throwing an exception?
> >
> > if i call close then it throws exception which gets caught in catch 1
not in catch 2
> > can anybody explain
>
> I tried it on JDK 1.1.7v3. First, I did not get any exception that
> you got. Second, the program does not even go as far as the
> ss.close() statement: it blocks at ss.accept() (which is correct
> behaviour). If I then have a client connect to the port this program
> is listening to, then the program continues and runs to completion
> without exception.
>
> In other words, I cannot reproduce your result.
>
> Complete program I used:
>
> import java.io.*;
> import java.net.*;
>
> public class SS
> {
> public static void main(String args[]) {
> ServerSocket ss = null;
> try
> {
> ss = new ServerSocket(3856);
> }
> catch (Exception e)
> {
> System.out.println("0");
> }
>
> try
> {
> ss.accept();
> }
> catch(Exception e) /* 1 */
> {
> System.out.println("1");
> }
>
> try
> {
> ss.close();
> }
> catch(Exception e) /* 2 */
> {
> System.out.println("2");
> }
> }
> }
>
> --
> [If you post a response, no need to cc me; if you cc me, please say so.]
> A compiler always tells the truth and calls a spade a spade.
>
>
> ----------------------------------------------------------------------
> To UNSUBSCRIBE, email to [EMAIL PROTECTED]
> with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
>
>
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]