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:
@ -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)
|
||||
{
|
||||
|
Reference in New Issue
Block a user