Connection pool

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 Params Creation parameters
FUNCTIONS
void Close(dmConnectionPool::HPool pool, dmConnectionPool::HConnection connection) Close connection. Use this function whenever an er...
 Delete(dmConnectionPool::HPool pool) Delete connnection pool
 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
 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 GetSocket(dmConnectionPool::HPool pool, dmConnectionPool::HConnection connection) Get socket for connection
dmSSLSocket::Socket GetSSLSocket(dmConnectionPool::HPool pool, dmConnectionPool::HConnection connection) Get secure socket.
 New(dmConnectionPool::Params* params, dmConnectionPool::HPool* pool) Create a new connection pool
void Return(dmConnectionPool::HPool pool, dmConnectionPool::HConnection connection) Return connection to pool
 Shutdown(dmConnectionPool::HPool pool, dmSocket::ShutdownType how) Shuts down all open sockets in the pool and block ...

Functions

Close

void 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

Delete

 Delete(dmConnectionPool::HPool pool)

Delete connnection pool

PARAMETERS

dmConnectionPool::HPool pool pool

RETURNS

on success

Dial

 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

Dial

 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

GetSocket

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

Get socket for connection

PARAMETERS

dmConnectionPool::HPool pool pool
dmConnectionPool::HConnection connection

RETURNS

dmSocket::Socket on success

GetSSLSocket

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

Get secure socket.

PARAMETERS

dmConnectionPool::HPool pool pool
dmConnectionPool::HConnection connection

RETURNS

dmSSLSocket::Socket on success

New

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

Create a new connection pool

PARAMETERS

dmConnectionPool::Params* params
dmConnectionPool::HPool* pool pool (out)

RETURNS

on success

Return

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

Return connection to pool

PARAMETERS

dmConnectionPool::HPool pool pool
dmConnectionPool::HConnection connection

Shutdown

 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

Params

TYPE

struct 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