Package org.apache.http.nio.impl.reactor

Examples of org.apache.http.nio.impl.reactor.DefaultConnectingIOReactor


            .setIntParameter(HttpConnectionParams.SOCKET_BUFFER_SIZE, 8 * 1024)
            .setBooleanParameter(HttpConnectionParams.STALE_CONNECTION_CHECK, false)
            .setBooleanParameter(HttpConnectionParams.TCP_NODELAY, true)
            .setParameter(HttpProtocolParams.USER_AGENT, "Jakarta-HttpComponents-NIO/1.1");

        ConnectingIOReactor ioReactor = new DefaultConnectingIOReactor(2, params);

        SessionRequest[] reqs = new SessionRequest[3];
        reqs[0] = ioReactor.connect(
                new InetSocketAddress("www.yahoo.com", 80),
                null,
                new HttpHost("www.yahoo.com"));
        reqs[1] = ioReactor.connect(
                new InetSocketAddress("www.google.com", 80),
                null,
                new HttpHost("www.google.ch"));
        reqs[2] = ioReactor.connect(
                new InetSocketAddress("www.apache.org", 80),
                null,
                new HttpHost("www.apache.org"));

        NHttpClientHandler handler = new MyNHttpClientHandler(reqs, params);
        IOEventDispatch ioEventDispatch = new DefaultClientIOEventDispatch(handler, params);
       
        try {
            ioReactor.execute(ioEventDispatch);
        } catch (InterruptedIOException ex) {
            System.err.println("Interrupted");
        } catch (IOException e) {
            System.err.println("I/O error: " + e.getMessage());
        }
View Full Code Here

TOP

Related Classes of org.apache.http.nio.impl.reactor.DefaultConnectingIOReactor

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.