Package org.xsocket.connection

Examples of org.xsocket.connection.INonBlockingConnection


      SSLContext sslContext = SSLTestContextFactory.getSSLContext();
     
        IServer server = new HttpServer(0, new ContentEchoHandler(), sslContext, true);
        server.start();

        INonBlockingConnection tcpCon = new NonBlockingConnection("localhost", server.getLocalPort(), sslContext, true);
        HttpClientConnection con = new HttpClientConnection(tcpCon);
   
           
        FutureResponseHandler hdl = new FutureResponseHandler();
       
View Full Code Here


    FutureResponseHandler respHdl = new FutureResponseHandler();
    httpClient.send(new GetRequest("http://localhost:" + server.getLocalPort() + "/"), respHdl);

    IBlockingConnection serverCon = null;
    do {
      INonBlockingConnection nbc = dh.getConnection();
      if (nbc != null) {
        serverCon = new BlockingConnection(nbc);
      }
     } while (serverCon == null);
   
View Full Code Here

      SSLContext sslContext = SSLTestContextFactory.getSSLContext();
     
        IServer server = new HttpServer(0, new ContentEchoHandler(), sslContext, true);
        server.start();

        INonBlockingConnection tcpCon = new NonBlockingConnection("localhost", server.getLocalPort(), sslContext, true);
        HttpClientConnection con = new HttpClientConnection(tcpCon);
   
           
        FutureResponseHandler hdl = new FutureResponseHandler();
       
View Full Code Here

    @Test
    public void testIdleTimeout() throws Exception {

        IServer server = new HttpServer(new DoNothingRequestHandler());
       
        INonBlockingConnection con = new NonBlockingConnection("localhost", server.getLocalPort());
        con.setIdleTimeoutMillis(1000);
       
        HttpClientConnection httpCon = new HttpClientConnection(con);
       
        ResponseHandler respHdl = new ResponseHandler();
        httpCon.send(new GetRequest("/"), respHdl);
View Full Code Here

    @Test
    public void testIdleTimeoutHandler() throws Exception {

        IServer server = new HttpServer(new DoNothingRequestHandler());
       
        INonBlockingConnection con = new NonBlockingConnection("localhost", server.getLocalPort());
        con.setIdleTimeoutMillis(1000);
       
        HttpClientConnection httpCon = new HttpClientConnection(con);
       
        ResponseHandler2 respHdl = new ResponseHandler2();
        httpCon.send(new GetRequest("/"), respHdl);
View Full Code Here

    FutureResponseHandler respHdl = new FutureResponseHandler();
    httpClient.send(new GetRequest("http://localhost:" + server.getLocalPort() + "/"), respHdl);

    IBlockingConnection serverCon = null;
    do {
      INonBlockingConnection nbc = dh.getConnection();
      if (nbc != null) {
        serverCon = new BlockingConnection(nbc);
      }
     } while (serverCon == null);
   
View Full Code Here

    httpClient.send(new GetRequest("http://localhost:" + server.getLocalPort() + "/"), respHdl);

    IBlockingConnection serverCon = null;
    long start = System.currentTimeMillis();
    do {
      INonBlockingConnection nbc = dh.getConnection();
      if (nbc != null) {
        serverCon = new BlockingConnection(nbc);
        break;
      }
      QAUtil.sleep(100);
View Full Code Here

     * @param targetHost       the target host
     * @param targetPort       the target port
     * @throws IOException if an exception occurs
     */
    public static void establishTcpTunnel(IHttpConnection httpConnection, String targetHost, int targetPort) throws IOException {
        INonBlockingConnection forwardCon = new NonBlockingConnection(targetHost, targetPort);
       
        INonBlockingConnection tcpCon = httpConnection.getUnderlyingTcpConnection();

        forwardCon.setAttachment(tcpCon);
        tcpCon.setAttachment(forwardCon);
           
        forwardCon.setFlushmode(FlushMode.ASYNC);
        forwardCon.setAutoflush(false);
        tcpCon.setFlushmode(FlushMode.ASYNC);
        tcpCon.setAutoflush(false);

        forwardCon.setHandler(new TcpProxyHandler());
        tcpCon.setHandler(new TcpProxyHandler());
    }
View Full Code Here

   
   
    private static class TcpProxyHandler implements IDataHandler, IDisconnectHandler {
       
        public boolean onDisconnect(INonBlockingConnection connection) throws IOException {
            INonBlockingConnection reverseConnection = (INonBlockingConnection) connection.getAttachment();
            if (reverseConnection != null) {
                connection.setAttachment(null);
                NonBlockingConnectionPool.destroy(reverseConnection);
            }
            return true;
View Full Code Here

            return true;
        }
       
       
        public boolean onData(INonBlockingConnection connection) throws IOException, BufferUnderflowException, MaxReadSizeExceededException {
            INonBlockingConnection forwardConnection = (INonBlockingConnection) connection.getAttachment();
               
            int available = connection.available();
            if (available > 0) {
                ByteBuffer[] data = connection.readByteBufferByLength(connection.available());
                forwardConnection.write(data);
                forwardConnection.flush();
               
            } else if (available == -1) {
                NonBlockingConnectionPool.destroy(connection);
            }
           
View Full Code Here

TOP

Related Classes of org.xsocket.connection.INonBlockingConnection

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.