1
0
mirror of https://frontier.innolan.net/rainlance/c-ares.git synced 2025-10-06 03:29:34 +00:00

Add ares_set_socket_configure_callback()

This function sets a callback that is invoked after the socket is
created, but before the connection is established.  This is an ideal
time to customize various socket options.
This commit is contained in:
Andrew Ayer
2016-02-06 09:20:41 -08:00
parent 87d641a907
commit 11e37a92ef
8 changed files with 127 additions and 1 deletions

View File

@ -1031,6 +1031,17 @@ static int open_tcp_socket(ares_channel channel, struct server_state *server)
}
#endif
if (channel->sock_config_cb)
{
int err = channel->sock_config_cb(s, SOCK_STREAM,
channel->sock_config_cb_data);
if (err < 0)
{
sclose(s);
return err;
}
}
/* Connect to the server. */
if (connect(s, sa, salen) == -1)
{
@ -1115,6 +1126,17 @@ static int open_udp_socket(ares_channel channel, struct server_state *server)
return -1;
}
if (channel->sock_config_cb)
{
int err = channel->sock_config_cb(s, SOCK_DGRAM,
channel->sock_config_cb_data);
if (err < 0)
{
sclose(s);
return err;
}
}
/* Connect to the server. */
if (connect(s, sa, salen) == -1)
{