Add API to register callback to set socket options

The registered callback function will be called before connect() is
called on the socket, allowing tweaking of much more than just keepalive
settings.

This deprecates xmpp_conn_set_keepalive().

Includes helper/example callback function to set default keepalive
parameters that some library users may find useful.
This commit is contained in:
Stu Tomlinson
2022-03-16 11:28:09 +00:00
parent 97b1452211
commit 06afe3d1c2
10 changed files with 356 additions and 64 deletions

View File

@@ -174,6 +174,7 @@ struct _xmpp_conn_t {
sock_t sock;
int ka_timeout; /* TCP keepalive timeout */
int ka_interval; /* TCP keepalive interval */
int ka_count; /* TCP keepalive count */
tls_t *tls;
int tls_support;
@@ -233,6 +234,7 @@ struct _xmpp_conn_t {
xmpp_handlist_t *timed_handlers;
hash_t *id_handlers;
xmpp_handlist_t *handlers;
xmpp_sockopt_callback sockopt_cb;
};
void conn_disconnect(xmpp_conn_t *conn);