Package java.net

Examples of java.net.SocketTimeoutException


            tcpRegistrationLock.wait(100);
          } catch (InterruptedException ignored) {
          }
        }
        if (!tcpRegistered) {
          throw new SocketTimeoutException("Connected, but timed out during TCP registration.\n"
            + "Note: Client#update must be called in a separate thread during connect.");
        }
      }

      if (udpPort != -1) {
        InetSocketAddress udpAddress = new InetSocketAddress(host, udpPort);
        synchronized (updateLock) {
          udpRegistered = false;
          selector.wakeup();
          udp.connect(selector, udpAddress);
        }

        // Wait for RegisterUDP reply.
        synchronized (udpRegistrationLock) {
          while (!udpRegistered && System.currentTimeMillis() < endTime) {
            RegisterUDP registerUDP = new RegisterUDP();
            registerUDP.connectionID = id;
            udp.send(this, registerUDP, udpAddress);
            try {
              udpRegistrationLock.wait(100);
            } catch (InterruptedException ignored) {
            }
          }
          if (!udpRegistered)
            throw new SocketTimeoutException("Connected, but timed out during UDP registration: " + host + ":" + udpPort);
        }
      }
    } catch (IOException ex) {
      close();
      throw ex;
View Full Code Here


    testCreateThrowable(new NullPointerException("A test NPE"), //$NON-NLS-1$
        SQLStates.DEFAULT);
    testCreateThrowable(new ProcedureErrorInstructionException(
        "A test SQL Procedure Error exception"), //$NON-NLS-1$
        SQLStates.VIRTUAL_PROCEDURE_ERROR);
    testCreateThrowable(new SocketTimeoutException(
        "A test socket timeout exception"), //$NON-NLS-1$
        SQLStates.CONNECTION_EXCEPTION_STALE_CONNECTION);
    testCreateThrowable(
        new UnknownHostException("A test connection attempt exception"), //$NON-NLS-1$
        SQLStates.CONNECTION_EXCEPTION_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION);
View Full Code Here

    testCreateThrowable(new CommunicationException(new SocketException(
        "A test java.net.SocketException"), //$NON-NLS-1$
        "Test Communication Exception with a SocketException in it"), //$NON-NLS-1$
        SQLStates.CONNECTION_EXCEPTION_STALE_CONNECTION);
    testCreateThrowable(
        new TeiidException(new SocketTimeoutException(
            "A test java.net.SocketTimeoutException"), //$NON-NLS-1$
            "Test MetaMatrixException with a SocketTimeoutException in it"), //$NON-NLS-1$
        SQLStates.CONNECTION_EXCEPTION_STALE_CONNECTION);
  }
View Full Code Here

   
    public void testCreateThrowable3() {
        TeiidSQLException e = testCreateThrowable(
                            new TeiidException(
                                    new TeiidRuntimeException(
                                            new SocketTimeoutException(
                                                    "A test MM Invalid Session Exception"), //$NON-NLS-1$
                                            "Test MetaMatrixRuntimeException with a InvalidSessionException in it"), //$NON-NLS-1$
                                    "Test MM Core Exception with an MM Runtime Exception in it and an InvalidSessionException nested within"), //$NON-NLS-1$
                            SQLStates.CONNECTION_EXCEPTION_STALE_CONNECTION);
       
View Full Code Here

    InputStream is = new InputStream() {
      int count;
      @Override
      public int read() throws IOException {
        if (count++%2==0) {
          throw new SocketTimeoutException();
        }
        return bais.read();
      }
    };
    ObjectDecoderInputStream odis = new ObjectDecoderInputStream(new DataInputStream(is), Thread.currentThread().getContextClassLoader(), 1024);
View Full Code Here

   
  }

  @Test public void testHandshakeTimeout() throws Exception {
    SocketTimeoutException[] exs = new SocketTimeoutException[SocketServerInstanceImpl.HANDSHAKE_RETRIES];
    Arrays.fill(exs, new SocketTimeoutException());
    final FakeObjectChannel channel = new FakeObjectChannel(Arrays.asList(exs));
   
    try {
      createInstance(channel);
      fail("Exception expected"); //$NON-NLS-1$
View Full Code Here

    ssii.connect(channelFactory);
    return ssii;
  }
 
  @Test public void testSuccessfulHandshake() throws Exception {
    final FakeObjectChannel channel = new FakeObjectChannel(Arrays.asList(new Handshake(), new SocketTimeoutException()));
   
    SocketServerInstanceImpl instance = createInstance(channel);
   
    //no remote server is hooked up, so this will timeout
    ILogon logon = instance.getService(ILogon.class);
View Full Code Here

                            try {
                                message.wait(timeoutMillis);
                            } catch (InterruptedException ignore) { }
                           
                            if ((start - System.currentTimeMillis()) > timeoutMillis) {
                                throw new SocketTimeoutException("timeout " + DataConverter.toFormatedDuration(timeoutMillis) + " reached");
                            }
                        }
                    }
                   
                } while (!isComplete.get());
View Full Code Here

  @Override
  protected void onIdleTimeout() throws IOException {

      // notify waiting handler
        for (MessageHandler messageHandler : getHandlersWaitingForResponseCopy()) {
            messageHandler.onException(new SocketTimeoutException("idle timeout " + DataConverter.toFormatedDuration(getIdleTimeoutMillis()) + " reached"));
        }
        handlersWaitingForResponseHeader.clear();

      super.onIdleTimeout();
  }
View Full Code Here

  @Override
  protected void onConnectionTimeout() throws IOException {

    // notify waiting handler
    for (MessageHandler messageHandler : getHandlersWaitingForResponseCopy()) {
      messageHandler.onException(new SocketTimeoutException("connection timeout " + DataConverter.toFormatedDuration(getConnectionTimeoutMillis()) + " reached"));
    }
    handlersWaitingForResponseHeader.clear();

    super.onConnectionTimeout();
  }
View Full Code Here

TOP

Related Classes of java.net.SocketTimeoutException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.