I read the test program of Andreas.
When I use his codes, I got the exception Andreas mentioned.
However, I think this is due to the synchronization problem because
there are two threads there.
So, I do very small changes to his TestSocket.java file:
Then the problem is not there.
Regards
yangyuexiang
import java.net.*;
import java.io.*;
public class TestSocket
{
static InputStream in;
static int [] lock = new int[1];
static int [] lable = new int[1];
public static void main(String[] args)
{
try {
Socket socket = new Socket(args[0],Integer.parseInt(args[1]));
in = socket.getInputStream();
Thread t = new Thread()
{
public void run()
{
for (;;)
{
try {
System.out.println("before read");
synchronized(lock)
{
if(lable !=null)
in.read();
}
System.out.println("after read");
} catch (Exception e)
{
System.out.println("-------------");
e.printStackTrace();
return;
}
}
}
};
t.start();
System.out.println("sleeping");
Thread.currentThread().sleep(1000);
System.out.println("closing socket");
synchronized(lock)
{
socket.close();
lable = null;
}
System.out.println("closing socket done");
} catch (Exception e)
{
e.printStackTrace();
System.exit(-1);
}
}
}
-- ^ ^ (oo)\_______ (__)\ )\/\ ||----w | || ||
Welcome http://192.168.213.203