{
GSSDPClient *client = GSSDP_CLIENT (object);
GError *error = NULL;
+#ifdef G_OS_WIN32
+ WSADATA wsaData = {0};
+ if (WSAStartup (MAKEWORD (2,2), &wsaData) != 0) {
+ gchar *message;
+
+ message = g_win32_error_message (WSAGetLastError ());
+ g_set_error_literal (client->priv->error,
+ GSSDP_ERROR,
+ GSSDP_ERROR_FAILED,
+ message);
+ g_free (message);
+ }
+#endif
/* Make sure all network info is available to us */
if (!init_network_info (client))
GSSDPClient *client;
client = GSSDP_CLIENT (object);
+#ifdef G_OS_WIN32
+ WSACleanup ();
+#endif
g_free (client->priv->server_id);
g_free (client->priv->iface);
error);
}
+#ifdef G_OS_WIN32
+gboolean
+gssdp_socket_reuse_address (GSocket *socket,
+ gboolean enable,
+ GError **error) {
+ return gssdp_socket_option_set (socket,
+ SOL_SOCKET,
+ SO_REUSEADDR,
+ (char *) &enable,
+ sizeof (enable),
+ error);
+}
+#endif
+
+
/*
* Iface may be NULL if no special interface is wanted
*/
GInetAddress *group,
GInetAddress *iface,
GError **error);
+#ifdef G_OS_WIN32
+G_GNUC_INTERNAL gboolean
+gssdp_socket_reuse_address (GSocket *socket,
+ gboolean enable,
+ GError **error);
+#endif
#endif
SSDP_PORT);
}
+#ifdef G_OS_WIN32
+ /* normally g_socket_bind does this, but it is disabled on
+ * windows since SO_REUSEADDR has different semantics
+ * there. Nevertheless, there's no way without for
+ * multicast sockets
+ */
+ if (!gssdp_socket_reuse_address (self->priv->socket,
+ TRUE,
+ &inner_error)) {
+ g_propagate_prefixed_error (
+ error,
+ inner_error,
+ "Failed to enable reuse");
+
+ goto error;
+ }
+#endif
/* Bind to requested port and address */
if (!g_socket_bind (self->priv->socket,
bind_address,