static int g_socket_output_stream_get_fd (GFileDescriptorBased *fd_based) { GSocketOutputStream *output_stream = G_SOCKET_OUTPUT_STREAM (fd_based); return g_socket_get_fd (output_stream->priv->socket); }
static gboolean g_socket_output_stream_pollable_is_writable (GPollableOutputStream *pollable) { GSocketOutputStream *output_stream = G_SOCKET_OUTPUT_STREAM (pollable); return g_socket_condition_check (output_stream->priv->socket, G_IO_OUT); }
static gboolean g_socket_output_stream_writev (GOutputStream *stream, const GOutputVector *vectors, gsize n_vectors, gsize *bytes_written, GCancellable *cancellable, GError **error) { GSocketOutputStream *output_stream = G_SOCKET_OUTPUT_STREAM (stream); GPollableReturn res; /* Clamp the number of vectors if more given than we can write in one go. * The caller has to handle short writes anyway. */ if (n_vectors > G_MAXINT) n_vectors = G_MAXINT; res = g_socket_send_message_with_timeout (output_stream->priv->socket, NULL, vectors, n_vectors, NULL, 0, G_SOCKET_MSG_NONE, -1, bytes_written, cancellable, error); /* we have a non-zero timeout so this can't happen */ g_assert (res != G_POLLABLE_RETURN_WOULD_BLOCK); return res == G_POLLABLE_RETURN_OK; }
static void g_socket_output_stream_finalize (GObject *object) { GSocketOutputStream *stream = G_SOCKET_OUTPUT_STREAM (object); if (stream->priv->socket) g_object_unref (stream->priv->socket); G_OBJECT_CLASS (g_socket_output_stream_parent_class)->finalize (object); }
static gssize g_socket_output_stream_pollable_write_nonblocking (GPollableOutputStream *pollable, const void *buffer, gsize size, GError **error) { GSocketOutputStream *output_stream = G_SOCKET_OUTPUT_STREAM (pollable); return g_socket_send_with_blocking (output_stream->priv->socket, buffer, size, FALSE, NULL, error); }
static gssize g_socket_output_stream_write (GOutputStream *stream, const void *buffer, gsize count, GCancellable *cancellable, GError **error) { GSocketOutputStream *onput_stream = G_SOCKET_OUTPUT_STREAM (stream); return g_socket_send_with_blocking (onput_stream->priv->socket, buffer, count, TRUE, cancellable, error); }
static GSource * g_socket_output_stream_pollable_create_source (GPollableOutputStream *pollable, GCancellable *cancellable) { GSocketOutputStream *output_stream = G_SOCKET_OUTPUT_STREAM (pollable); GSource *socket_source, *pollable_source; pollable_source = g_pollable_source_new (G_OBJECT (output_stream)); socket_source = g_socket_create_source (output_stream->priv->socket, G_IO_OUT, cancellable); g_source_set_dummy_callback (socket_source); g_source_add_child_source (pollable_source, socket_source); g_source_unref (socket_source); return pollable_source; }
static void g_socket_output_stream_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { GSocketOutputStream *stream = G_SOCKET_OUTPUT_STREAM (object); switch (prop_id) { case PROP_SOCKET: stream->priv->socket = g_value_dup_object (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } }
static GPollableReturn g_socket_output_stream_pollable_writev_nonblocking (GPollableOutputStream *pollable, const GOutputVector *vectors, gsize n_vectors, gsize *bytes_written, GError **error) { GSocketOutputStream *output_stream = G_SOCKET_OUTPUT_STREAM (pollable); /* Clamp the number of vectors if more given than we can write in one go. * The caller has to handle short writes anyway. */ if (n_vectors > G_MAXINT) n_vectors = G_MAXINT; return g_socket_send_message_with_timeout (output_stream->priv->socket, NULL, vectors, n_vectors, NULL, 0, G_SOCKET_MSG_NONE, 0, bytes_written, NULL, error); }
GSocketOutputStream * _g_socket_output_stream_new (GSocket *socket) { return G_SOCKET_OUTPUT_STREAM (g_object_new (G_TYPE_SOCKET_OUTPUT_STREAM, "socket", socket, NULL)); }