Ignore error when setting SO_REUSEADDR

The main error would be "not supported" which could happen for e.g.
unix domain sockets, we don't really care, as this is mainly something
for TCP to help out a bit.
This commit is contained in:
Alexander Larsson 2009-05-18 23:24:13 +02:00
parent f24c7fa9cb
commit 3756ddb0ee

View File

@ -1342,15 +1342,10 @@ g_socket_bind (GSocket *socket,
It always allows the unix variant of SO_REUSEADDR anyway */
#ifndef G_OS_WIN32
value = (int) !!reuse_address;
if (setsockopt (socket->priv->fd, SOL_SOCKET, SO_REUSEADDR,
(gpointer) &value, sizeof (value)) < 0)
{
int errsv = get_socket_errno ();
g_set_error (error,
G_IO_ERROR, socket_io_error_from_errno (errsv),
_("Error setting reuse_address: %s"), socket_strerror (errsv));
return FALSE;
}
/* Ignore errors here, the only likely error is "not supported", and
this is a "best effort" thing mainly */
setsockopt (socket->priv->fd, SOL_SOCKET, SO_REUSEADDR,
(gpointer) &value, sizeof (value));
#endif
if (!g_socket_address_to_native (address, addr, sizeof addr, error))