if ((ret = accept (socket->priv->fd, NULL, 0)) < 0)
{
- g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errno), "error accepting connection");
+ g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errno), "error accepting connection: %s", g_strerror (errno));
return NULL;
}
if ((ret = send (socket->priv->fd, buffer, size, 0)) < 0)
{
- g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errno), "error receiving data: %s", g_strerror (errno));
+ g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errno), "error sending data: %s", g_strerror (errno));
return -1;
}
close (socket->priv->fd);
#endif
}
+
+GSource *
+g_socket_create_source (GSocket *socket,
+ GIOCondition condition,
+ GCancellable *cancellable)
+{
+ g_return_val_if_fail (G_IS_SOCKET (socket) && (cancellable == NULL || G_IS_CANCELLABLE (cancellable)), NULL);
+
+ return _g_fd_source_new (socket->priv->fd, G_IO_IN | G_IO_HUP | G_IO_ERR, cancellable);
+}