How can i create a long connection use this ?
Opened this issue · 4 comments
Brief overview
Hi, I'm new to network programming, i want to use this library to write a simple http client. But i don't know how to create a long connection by this library, i want send multiple http request in one connection. Could someone please help me?
Thank you for your interest in EasyHttp.
EasyHttp supports connection pooling.
Have a look at the SimpleHttpClient sample.
You can configure a connection pool when creating EasyHttp client instance.
Thank you for your interest in EasyHttp.
EasyHttp supports connection pooling.
Have a look at the SimpleHttpClient sample.You can configure a connection pool when creating EasyHttp client instance.
Think you for your fast response. I like EasyHttp.
I have read SimpleHttpClient sample. I would like to read the source code too, but now i don't have much time. So maybe my question it too naive. The question is: i don't know how to reuse the connection in the connection pool. Could you give me a code piece about that please?
i don't know how to reuse the connection in the connection pool. Could you give me a code piece about that please?
Ah, EasyHttp will take care of connection pooling automatically for you once configured.
When configuring the connection pool, you can set two parameters as shown below:
- Maximum no of idle collections in connection pool
- Keep-alive timeout in seconds
//max no of idle collections in connection pool
unsigned int keepAliveIdleCountMax = 10;
// keep-alive timeout second
unsigned long keepAliveTimeoutSec = 60;
// EasyHttp will keep-alive keepAliveIdleCountMax idle connections in parallel for keepAliveTimeoutSec seconds
easyhttpcpp::ConnectionPool::Ptr pConnectionPool = easyhttpcpp::ConnectionPool::createConnectionPool(keepAliveIdleCountMax, keepAliveTimeoutSec);
i don't know how to reuse the connection in the connection pool. Could you give me a code piece about that please?
Ah, EasyHttp will take care of connection pooling automatically for you once configured. When configuring the connection pool, you can set two parameters as shown below:
- Maximum no of idle collections in connection pool
- Keep-alive timeout in seconds
//max no of idle collections in connection pool unsigned int keepAliveIdleCountMax = 10; // keep-alive timeout second unsigned long keepAliveTimeoutSec = 60; // EasyHttp will keep-alive keepAliveIdleCountMax idle connections in parallel for keepAliveTimeoutSec seconds easyhttpcpp::ConnectionPool::Ptr pConnectionPool = easyhttpcpp::ConnectionPool::createConnectionPool(keepAliveIdleCountMax, keepAliveTimeoutSec);
@shekharhimanshu I understood what you have explained , can you please tell then what does setCorePoolSizeOfAsyncThreadPool and setMaximumPoolSizeOfAsyncThreadPool do and what is their role
httpClientBuilder.setConnectionPool(pConnectionPool)
.setCorePoolSizeOfAsyncThreadPool(10)
.setMaximumPoolSizeOfAsyncThreadPool(10 + no_of_cores);