Sdk connection pool api documentation

Connection pool

Namespace: dmConnectionPool
Include: #include <dmsdk/dlib/connection_pool.h>
TYPES
HConnection Connection handle
HPool Connection pool handle
ENUMS
dmConnectionPool::Result result enumeration
STRUCTS
struct dmConnectionPool::Params Creation parameters
FUNCTIONS
void dmConnectionPool::Close(dmConnectionPool::HPool pool, dmConnectionPool::HConnection connection) Close connection. Use this function whenever an er...
 dmConnectionPool::Delete(dmConnectionPool::HPool pool) Delete connnection pool
 dmConnectionPool::Dial(dmConnectionPool::HPool pool, const char* host, uint16_t port, bool ssl, int timeout, dmConnectionPool::HConnection* connection, dmSocket::Result* sock_res) Connection to a host/port
 dmConnectionPool::Dial(dmConnectionPool::HPool pool, const char* host, uint16_t port, bool ssl, int timeout, int* cancelflag, dmConnectionPool::HConnection* connection, dmSocket::Result* sock_res) Connection to a host/port
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::New( params, dmConnectionPool::HPool* pool) Create a new connection pool
void dmConnectionPool::Return(dmConnectionPool::HPool pool, dmConnectionPool::HConnection connection) Return connection to pool
 dmConnectionPool::Shutdown(dmConnectionPool::HPool pool, dmSocket::ShutdownType how) Shuts down all open sockets in the pool and block ...

Functions

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::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, 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
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::Dial

 dmConnectionPool::Dial(dmConnectionPool::HPool pool, const char* host, uint16_t port, bool ssl, int timeout, int* cancelflag, 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
bool ssl true for ssl connection
int timeout The timeout (micro seconds) for the connection and ssl handshake
int* cancelflag If set and not null, will make the request early out
dmConnectionPool::HConnection* connection connection (out)
dmSocket::Result* sock_res socket-result code on failure

RETURNS

on success

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::New

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

Create a new connection pool

PARAMETERS

params
dmConnectionPool::HPool* pool pool (out)

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::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


Types

HConnection

Connection handle


HPool

Connection pool handle


Enums

dmConnectionPool::Result

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