Search in sources :

Example 96 with SocketException

use of java.net.SocketException in project robovm by robovm.

the class OldServerSocketTest method test_setReceiveBufferSizeI.

public void test_setReceiveBufferSizeI() throws IOException {
    ServerSocket newSocket = new ServerSocket();
    newSocket.close();
    try {
        newSocket.setReceiveBufferSize(10);
        fail("SocketException was not thrown.");
    } catch (SocketException se) {
    //expected
    }
}
Also used : SocketException(java.net.SocketException) ServerSocket(java.net.ServerSocket)

Example 97 with SocketException

use of java.net.SocketException in project robovm by robovm.

the class OldServerSocketTest method test_setReuseAddressZ.

public void test_setReuseAddressZ() throws IOException {
    ServerSocket newSocket = new ServerSocket();
    newSocket.close();
    try {
        newSocket.setReuseAddress(true);
        fail("SocketException was not thrown.");
    } catch (SocketException expected) {
    }
}
Also used : SocketException(java.net.SocketException) ServerSocket(java.net.ServerSocket)

Example 98 with SocketException

use of java.net.SocketException in project robovm by robovm.

the class OldSocketImplFactoryTest method test_createSocketImpl.

public void test_createSocketImpl() throws IOException {
    MockSocketImplFactory factory = new MockSocketImplFactory();
    if (isTestable) {
        assertFalse(isCreateSocketImpl);
        Socket.setSocketImplFactory(factory);
        try {
            new Socket();
            assertTrue(isCreateSocketImpl);
            assertTrue(iSocketImplCalled);
        } catch (Exception e) {
            fail("Exception during test : " + e.getMessage());
        }
        try {
            Socket.setSocketImplFactory(factory);
            fail("SocketException was not thrown.");
        } catch (SocketException se) {
        //expected
        }
        try {
            Socket.setSocketImplFactory(null);
            fail("SocketException was not thrown.");
        } catch (SocketException se) {
        //expected
        }
    } else {
        SocketImpl si = factory.createSocketImpl();
        try {
            assertNull(si.getOption(0));
        } catch (SocketException e) {
            fail("SocketException was thrown.");
        }
    }
}
Also used : SocketException(java.net.SocketException) SocketImpl(java.net.SocketImpl) Socket(java.net.Socket) SocketException(java.net.SocketException) IOException(java.io.IOException)

Example 99 with SocketException

use of java.net.SocketException in project robovm by robovm.

the class OldSocketTest method test_setSendBufferSizeI.

public void test_setSendBufferSizeI() {
    try {
        int sport = startServer("SServer setSendBufferSizeI");
        s = new Socket(InetAddress.getLocalHost(), sport, null, 0);
        s.setSendBufferSize(134);
        assertTrue("Incorrect buffer size", s.getSendBufferSize() >= 134);
        ensureExceptionThrownIfOptionIsUnsupportedOnOS(SO_SNDBUF);
    } catch (Exception e) {
        handleException(e, SO_SNDBUF);
    }
    try {
        Socket theSocket = new Socket();
        theSocket.close();
        theSocket.setSendBufferSize(1);
        fail("SocketException was not thrown.");
    } catch (SocketException ioe) {
    //expected
    } catch (IOException ioe) {
        fail("IOException was thrown.");
    }
}
Also used : SocketException(java.net.SocketException) IOException(java.io.IOException) Socket(java.net.Socket) ServerSocket(java.net.ServerSocket) IOException(java.io.IOException) BindException(java.net.BindException) UnknownHostException(java.net.UnknownHostException) SocketException(java.net.SocketException) IllegalBlockingModeException(java.nio.channels.IllegalBlockingModeException) SocketTimeoutException(java.net.SocketTimeoutException) ConnectException(java.net.ConnectException)

Example 100 with SocketException

use of java.net.SocketException in project robovm by robovm.

the class OldSocketTest method test_setTcpNoDelayZ.

public void test_setTcpNoDelayZ() {
    // Test for method void java.net.Socket.setTcpNoDelay(boolean)
    try {
        int sport = startServer("SServer setTcpNoDelayZ");
        s = new Socket(InetAddress.getLocalHost(), sport, null, 0);
        boolean bool;
        s.setTcpNoDelay(bool = !s.getTcpNoDelay());
        assertTrue("Failed to set no delay setting: " + s.getTcpNoDelay(), s.getTcpNoDelay() == bool);
        ensureExceptionThrownIfOptionIsUnsupportedOnOS(TCP_NODELAY);
    } catch (Exception e) {
        handleException(e, TCP_NODELAY);
    }
    try {
        Socket theSocket = new Socket();
        theSocket.close();
        theSocket.setTcpNoDelay(true);
        fail("SocketException was not thrown.");
    } catch (SocketException ioe) {
    //expected
    } catch (IOException ioe) {
        fail("IOException was thrown.");
    }
}
Also used : SocketException(java.net.SocketException) IOException(java.io.IOException) Socket(java.net.Socket) ServerSocket(java.net.ServerSocket) IOException(java.io.IOException) BindException(java.net.BindException) UnknownHostException(java.net.UnknownHostException) SocketException(java.net.SocketException) IllegalBlockingModeException(java.nio.channels.IllegalBlockingModeException) SocketTimeoutException(java.net.SocketTimeoutException) ConnectException(java.net.ConnectException)

Aggregations

SocketException (java.net.SocketException)488 IOException (java.io.IOException)172 InetAddress (java.net.InetAddress)122 NetworkInterface (java.net.NetworkInterface)106 Socket (java.net.Socket)96 UnknownHostException (java.net.UnknownHostException)85 ServerSocket (java.net.ServerSocket)79 DatagramSocket (java.net.DatagramSocket)75 SocketTimeoutException (java.net.SocketTimeoutException)71 InetSocketAddress (java.net.InetSocketAddress)60 Test (org.junit.Test)41 ConnectException (java.net.ConnectException)38 DatagramPacket (java.net.DatagramPacket)35 BindException (java.net.BindException)31 ArrayList (java.util.ArrayList)31 SocketAddress (java.net.SocketAddress)24 Inet4Address (java.net.Inet4Address)23 IllegalBlockingModeException (java.nio.channels.IllegalBlockingModeException)23 InterruptedIOException (java.io.InterruptedIOException)21 SmallTest (android.test.suitebuilder.annotation.SmallTest)20