Re: SO_BINDTODEVICE with SoupSocket



On 12/19/2012 01:54 AM, Thomas Bechtold wrote:
> Hi,
> 
> I would like to implement device based connectivity checks for
> NetworkManager (see [1]) but I guess I need to use SO_BINDTODEVICE for
> the socket. Is that possible with libsoup?

Yes... first you need to set the SOUP_MESSAGE_NEW_CONNECTION flag on the
SoupMessage, to guarantee that it gets sent on a new connection rather
than reusing an existing one.

Then connect to the "network-event" signal on the message and send the
message off. The handler for that signal will be called several times
during the network connection process; when it gets gets called with an
event of G_SOCKET_CLIENT_CONNECTING, call
g_socket_connection_get_socket() on the connection, and then
g_socket_get_fd() on the socket, and then you can setsockopt() on the fd
to set SO_BINDTODEVICE.

-- Dan



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]