poser
A C framework for POsix SERvices
Loading...
Searching...
No Matches
PSC_TcpClientOpts Class Reference

Options for creating a TCP client. More...

#include <poser/core/client.h>

Public Member Functions

PSC_TcpClientOptsPSC_TcpClientOpts_create (const char *remotehost, int port)
 PSC_TcpClientOpts constructor.
 
void PSC_TcpClientOpts_readBufSize (PSC_TcpClientOpts *self, size_t sz)
 Set read buffer size.
 
void PSC_TcpClientOpts_enableTls (PSC_TcpClientOpts *self, const char *certfile, const char *keyfile)
 Enable TLS for the connection.
 
void PSC_TcpClientOpts_disableCertVerify (PSC_TcpClientOpts *self)
 Disable server certificate verification.
 
void PSC_TcpClientOpts_setProto (PSC_TcpClientOpts *self, PSC_Proto proto)
 Set a specific protocol (IPv4 or IPv6).
 
void PSC_TcpClientOpts_numericHosts (PSC_TcpClientOpts *self)
 Only use numeric hosts, don't attempt to resolve addresses.
 
void PSC_TcpClientOpts_setBlacklistHits (PSC_TcpClientOpts *self, int blacklistHits)
 Enable blacklisting of failed remote addresses.
 
void PSC_TcpClientOpts_destroy (PSC_TcpClientOpts *self)
 PSC_TcpClientOpts destructor.
 

Detailed Description

Options for creating a TCP client.

Member Function Documentation

◆ PSC_TcpClientOpts_create()

PSC_TcpClientOpts * PSC_TcpClientOpts_create ( const char *  remotehost,
int  port 
)

PSC_TcpClientOpts constructor.

Creates an options object initialized to default values.

Parameters
remotehosthost to connect to (name or address)
portport to connect to
Returns
a newly created options object

◆ PSC_TcpClientOpts_destroy()

void PSC_TcpClientOpts_destroy ( PSC_TcpClientOpts self)

PSC_TcpClientOpts destructor.

Parameters
selfthe PSC_TcpClientOpts

◆ PSC_TcpClientOpts_disableCertVerify()

void PSC_TcpClientOpts_disableCertVerify ( PSC_TcpClientOpts self)

Disable server certificate verification.

Parameters
selfthe PSC_TcpClientOpts

◆ PSC_TcpClientOpts_enableTls()

void PSC_TcpClientOpts_enableTls ( PSC_TcpClientOpts self,
const char *  certfile,
const char *  keyfile 
)

Enable TLS for the connection.

Enables TLS for the connection to be created, optionally using a client certificate.

Parameters
selfthe PSC_TcpClientOpts
certfilecertificate file for client certificate
keyfileprivate key file for client certificate

◆ PSC_TcpClientOpts_numericHosts()

void PSC_TcpClientOpts_numericHosts ( PSC_TcpClientOpts self)

Only use numeric hosts, don't attempt to resolve addresses.

Parameters
selfthe PSC_TcpClientOpts

◆ PSC_TcpClientOpts_readBufSize()

void PSC_TcpClientOpts_readBufSize ( PSC_TcpClientOpts self,
size_t  sz 
)

Set read buffer size.

Sets the size of the buffer used for reading from the connection, in bytes. The default value is 16 kiB.

Parameters
selfthe PSC_TcpClientOpts
szthe size of the read buffer, must be > 0

◆ PSC_TcpClientOpts_setBlacklistHits()

void PSC_TcpClientOpts_setBlacklistHits ( PSC_TcpClientOpts self,
int  blacklistHits 
)

Enable blacklisting of failed remote addresses.

When this is set to a non-zero value, a remote address is put on a blacklist after errors or timeouts during connect or TLS hanshake, or when closed with the blacklist parameter of PSC_Connection_close() set to 1.

This can be useful for remote services using some load-balancing or round-robin DNS. In this case, it can be avoided to try the same host over and over again.

Parameters
selfthe PSC_TcpClientOpts
blacklistHitsnumber of hits needed to remove the entry from the blacklist again

◆ PSC_TcpClientOpts_setProto()

void PSC_TcpClientOpts_setProto ( PSC_TcpClientOpts self,
PSC_Proto  proto 
)

Set a specific protocol (IPv4 or IPv6).

Parameters
selfthe PSC_TcpClientOpts
protoprotocol the client should use

The documentation for this class was generated from the following file: