Java 8 SocketException - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 SocketException class.

This code example shows how to use the following methods:
	} 
 
	@Test
	public void resolveMethodBestMatch() { 
		AnnotationExceptionHandlerMethodResolver resolver = new AnnotationExceptionHandlerMethodResolver(ExceptionController.class);
		SocketException exception = new SocketException();
		assertEquals("handleSocketException", resolver.resolveMethod(exception).getName());
	} 
 
	@Test
	public void resolveMethodNoMatch() { 
		AnnotationExceptionHandlerMethodResolver resolver = new AnnotationExceptionHandlerMethodResolver(ExceptionController.class);
		Exception exception = new Exception();
		assertNull("1st lookup", resolver.resolveMethod(exception));
		assertNull("2nd lookup from cache", resolver.resolveMethod(exception));
	} 
 
	@Test
	public void resolveMethodInherited() { 
		AnnotationExceptionHandlerMethodResolver resolver = new AnnotationExceptionHandlerMethodResolver(InheritedController.class);
7
CodeRank
This code example shows how to use the following methods:
		assertEquals("Invalid status code returned", 500, response.getStatus());
	} 
 
	@Test
	public void simpleWithSocketException() { 
		SocketException ex = new SocketException();
		SimpleController controller = new SimpleController();
		ModelAndView mav = exceptionResolver.resolveException(request, response, controller, ex);
		assertNotNull("No ModelAndView returned", mav);
		assertEquals("Invalid view name returned", "Y:SocketException", mav.getViewName());
		assertEquals("Invalid status code returned", 406, response.getStatus());
		assertEquals("Invalid status reason returned", "This is simply unacceptable!", response.getErrorMessage());
	} 
 
	@Test
	public void simpleWithFileNotFoundException() { 
		FileNotFoundException ex = new FileNotFoundException();
		SimpleController controller = new SimpleController();
		ModelAndView mav = exceptionResolver.resolveException(request, response, controller, ex);
		assertNotNull("No ModelAndView returned", mav);
7
CodeRank
This code example shows how to use the following methods:getMessage
 
        try { 
            reader = new ObjectInputStream(socket.getInputStream());
        } catch (SocketException e) {
            if (!isIgnorableException(e)) {
                logger.error("Reading Object", e);
            } 
            return null; 
        } catch (Exception e) {
            logger.error("Reading Object", e);
            return null; 
        } 
 
        try { 
            return reader.readObject();
        } catch (SocketException e) {
            //a connection reset is normal if the client quits, so don't dump out this exception and just return null. 
            if (!isIgnorableException(e)) {
                logger.error("Reading Object", e);
            } 

6
CodeRank
This code example shows how to use the following methods:toString
				System.out.println("SERVER inbound data port " + this.serverSocket.getLocalPort()
						+ " is ready and waiting for client to connect..."); 
			} 
		} catch (SocketException se) {
			System.err.println("Unable to create socket.");
			System.err.println(se.toString());
			System.exit(1);
		} catch (IOException ioe) {
			System.err.println("Unable to read data from an open socket.");
			System.err.println(ioe.toString());
			System.exit(1);
		} 
	} 
 
	/** 
	 * Run this class as an application. 
	 */ 
	public static void main(String[] args) {
		new TcpServer(); 
	} 
6
CodeRank
This code example shows how to use the following methods:getMessage
      System.err.println("Got exception: " + ce);
      assertTrue(ce.getMessage().contains("resulted in a loopback"));
    } catch (SocketException se) {
      // Some TCP stacks will actually throw their own Invalid argument exception 
      // here. This is also OK. 
      assertTrue(se.getMessage().contains("Invalid argument"));
    } 
  } 
   
  @Test 
  public void testSocketReadTimeoutWithChannel() throws Exception { 
    doSocketReadTimeoutTest(true); 
  } 
   
  @Test 
  public void testSocketReadTimeoutWithoutChannel() throws Exception { 
    doSocketReadTimeoutTest(false); 
  } 
 
   
6
CodeRank
This code example shows how to use the following methods:
    public void testClosetMatch3() { 
        setupPolicies(); 
        OnExceptionDefinition result = strategy.getExceptionPolicy(policies, null, new ConnectException(""));
        assertEquals(type3, result);
 
        result = strategy.getExceptionPolicy(policies, null, new SocketException(""));
        assertEquals(type3, result);
 
        result = strategy.getExceptionPolicy(policies, null, new FileNotFoundException());
        assertEquals(type3, result);
    } 
 
    public void testClosetMatch2() { 
        setupPolicies(); 
        OnExceptionDefinition result = strategy.getExceptionPolicy(policies, null, new ClassCastException(""));
        assertEquals(type2, result);
 
        result = strategy.getExceptionPolicy(policies, null, new NumberFormatException(""));
        assertEquals(type2, result);
 
5
CodeRank
This code example shows how to use the following methods:printStackTrace
 
    try { 
      this.ds = new DatagramSocket();
    } 
    catch (SocketException e) {
      e.printStackTrace();
      LogLog.error("Could not instantiate DatagramSocket to " + host +
			 ". All logging will FAIL.", e);
    } 
     
  } 
 
 
  public 
  void write(char[] buf, int off, int len) throws IOException {
    this.write(new String(buf, off, len));
  } 
   
  public 
  void write(final String string) throws IOException {
5
CodeRank
This code example shows how to use the following methods:printStackTrace
This code example shows how to use the following methods:printStackTrace
 
    try { 
      this.ds = new DatagramSocket();
    } 
    catch (SocketException e) {
      e.printStackTrace();
      LogLog.error("Could not instantiate DatagramSocket to " + host +
			 ". All logging will FAIL.", e);
    } 
  } 
 
 
  public 
  void write(char[] buf, int off, int len) throws IOException {
    this.write(new String(buf, off, len));
  } 
 
  public 
  void write(String string) throws IOException {
    if (prefix != null) {
5
CodeRank
This code example shows how to use the following methods:printStackTrace
        try { 
            fac.createSocket();
        } catch(SocketException se) {
            // if exception caught, then it's ok 
            System.out.println("Throw SocketException");
            se.printStackTrace();
            return; 
        } 
        throw new Exception("should throw SocketException");
        // if not caught, or other exception caught, then it's error 
    } 
} 
5
CodeRank

Related Java 8 SocketException Questions & Answers:

See Code Examples for Java 8 SocketException Methods: