Code example for ServerSocket

Methods: accept

0
 * Test that Socket.close called on another thread interrupts a thread that's blocked doing 
 * network I/O. 
 */ 
public class ConcurrentCloseTest extends junit.framework.TestCase {
    public void test_accept() throws Exception { 
        ServerSocket s = new ServerSocket(0);
        new Killer(s).start();
        try { 
            System.err.println("accept...");
            s.accept();
            fail("accept returned!");
        } catch (SocketException expected) {
            assertEquals("Socket closed", expected.getMessage());
        } 
    } 
 
    public void test_connect() throws Exception { 
        StuckServer ss = new StuckServer();
        Socket s = new Socket();
        new Killer(s).start();
        try {