Sdk connection pool api documentation

Connection pool

Namespace: dmConnectionPool
Include: #include <dmsdk/dlib/connection_pool.h>
ENUMS
dmConnectionPool::Result result enumeration
STRUCTS
struct dmConnectionPool::Params Creation parameters
FUNCTIONS
 dmConnectionPool::New( params, dmConnectionPool::HPool* pool) Create a new connection pool
 dmConnectionPool::Delete(dmConnectionPool::HPool pool) Delete connnection pool
 dmConnectionPool::Dial(dmConnectionPool::HPool pool, const char* host, uint16_t port, dmDNS::HChannel dns_channel, bool ssl, int timeout, dmConnectionPool::HConnection* connection, dmSocket::Result* sock_res) Connection to a host/port
void dmConnectionPool::Return(dmConnectionPool::HPool pool, dmConnectionPool::HConnection connection) Return connection to pool
void dmConnectionPool::Close(dmConnectionPool::HPool pool, dmConnectionPool::HConnection connection) Close connection. Use this function whenever an er...
dmSocket::Socket dmConnectionPool::GetSocket(dmConnectionPool::HPool pool, dmConnectionPool::HConnection connection) Get socket for connection
dmSSLSocket::Socket dmConnectionPool::GetSSLSocket(dmConnectionPool::HPool pool, dmConnectionPool::HConnection connection) Get secure socket.
 dmConnectionPool::Shutdown(dmConnectionPool::HPool pool, dmSocket::ShutdownType how) Shuts down all open sockets in the pool and block ...

Functions

dmConnectionPool::New

 dmConnectionPool::New( params, dmConnectionPool::HPool* pool)

Create a new connection pool

PARAMETERS

params
dmConnectionPool::HPool* pool pool (out)

RETURNS

on success

dmConnectionPool::Delete

 dmConnectionPool::Delete(dmConnectionPool::HPool pool)

Delete connnection pool

PARAMETERS

dmConnectionPool::HPool pool pool

RETURNS

on success

dmConnectionPool::Dial

 dmConnectionPool::Dial(dmConnectionPool::HPool pool, const char* host, uint16_t port, dmDNS::HChannel dns_channel, bool ssl, int timeout, dmConnectionPool::HConnection* connection, dmSocket::Result* sock_res)

Connection to a host/port

PARAMETERS

dmConnectionPool::HPool pool pool
const char* host host
uint16_t port port
dmDNS::HChannel dns_channel The DNS channel that will be used for translating the host to an address
bool ssl true for ssl connection
int timeout The timeout (micro seconds) for the connection and ssl handshake
dmConnectionPool::HConnection* connection connection (out)
dmSocket::Result* sock_res socket-result code on failure

RETURNS

on success

dmConnectionPool::Return

void dmConnectionPool::Return(dmConnectionPool::HPool pool, dmConnectionPool::HConnection connection)

Return connection to pool

PARAMETERS

dmConnectionPool::HPool pool pool
dmConnectionPool::HConnection connection

dmConnectionPool::Close

void dmConnectionPool::Close(dmConnectionPool::HPool pool, dmConnectionPool::HConnection connection)

Close connection. Use this function whenever an error occur in eg http.

PARAMETERS

dmConnectionPool::HPool pool pool
dmConnectionPool::HConnection connection

dmConnectionPool::GetSocket

dmSocket::Socket dmConnectionPool::GetSocket(dmConnectionPool::HPool pool, dmConnectionPool::HConnection connection)

Get socket for connection

PARAMETERS

dmConnectionPool::HPool pool pool
dmConnectionPool::HConnection connection

RETURNS

dmSocket::Socket on success

dmConnectionPool::GetSSLSocket

dmSSLSocket::Socket dmConnectionPool::GetSSLSocket(dmConnectionPool::HPool pool, dmConnectionPool::HConnection connection)

Get secure socket.

PARAMETERS

dmConnectionPool::HPool pool pool
dmConnectionPool::HConnection connection

RETURNS

dmSSLSocket::Socket on success

dmConnectionPool::Shutdown

 dmConnectionPool::Shutdown(dmConnectionPool::HPool pool, dmSocket::ShutdownType how)

Shuts down all open sockets in the pool and block new connection attempts. The function can be called repeatedly on the same pool until it returns no more connections in use.

PARAMETERS

dmConnectionPool::HPool pool pool
dmSocket::ShutdownType how shutdown type to pass to socket shutdown function

RETURNS

number of connections in use

Structs

dmConnectionPool::Params

TYPE

struct dmConnectionPool::Params

Creation parameters

MEMBERS

int m_MaxConnections Max connection in pool
int m_MaxKeepAlive Default max-keep-alive time in seconds


Enums

dmConnectionPool::Result

result enumeration

Result enumeration.

dmConnectionPool::RESULT_OK 0
dmConnectionPool::RESULT_OUT_OF_RESOURCES -1
dmConnectionPool::RESULT_SOCKET_ERROR -2
dmConnectionPool::RESULT_HANDSHAKE_FAILED -3
dmConnectionPool::RESULT_SHUT_DOWN -4