当前位置: 首页>>代码示例>>C++>>正文


C++ G_IO_STREAM函数代码示例

本文整理汇总了C++中G_IO_STREAM函数的典型用法代码示例。如果您正苦于以下问题:C++ G_IO_STREAM函数的具体用法?C++ G_IO_STREAM怎么用?C++ G_IO_STREAM使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了G_IO_STREAM函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: connect_cb

static void
connect_cb(GObject *source,
           GAsyncResult *res,
           gpointer user_data)
{
    GSocketConnection *socket_conn;
    PnNode *conn;
    GError *error = NULL;

    conn = PN_NODE(user_data);
    socket_conn = g_socket_client_connect_to_host_finish(G_SOCKET_CLIENT(source), res, &error);

    g_object_unref(source);

    if (error) {
        g_error_free(error);
        return;
    }

    g_object_ref(conn);

    if (socket_conn) {
        GSocket *socket;
        GInputStream *input;

        conn->socket_conn = socket_conn;
        socket = g_socket_connection_get_socket(socket_conn);

        conn->status = PN_NODE_STATUS_OPEN;

        input = g_io_stream_get_input_stream (G_IO_STREAM (conn->socket_conn));
        g_object_ref (conn);
        g_input_stream_read_async (input, conn->input_buffer, PN_BUF_LEN,
                                   G_PRIORITY_DEFAULT, NULL,
                                   read_cb, conn);
    }
    else {
        conn->error = g_error_new_literal(PN_NODE_ERROR, PN_NODE_ERROR_OPEN,
                                          "Unable to connect");

        pn_node_error(conn);
    }

    {
        PnNodeClass *class;
        class = g_type_class_peek(PN_NODE_TYPE);
        g_signal_emit(G_OBJECT(conn), class->open_sig, 0, conn);
    }

    g_object_unref(conn);
}
开发者ID:felipec,项目名称:msn-pecan,代码行数:51,代码来源:pn_node.c

示例2: xr_client_open

gboolean xr_client_open(xr_client_conn* conn, const char* uri, GError** err)
{
  GError* local_err = NULL;

  g_return_val_if_fail(conn != NULL, FALSE);
  g_return_val_if_fail(uri != NULL, FALSE);
  g_return_val_if_fail(!conn->is_open, FALSE);
  g_return_val_if_fail(err == NULL || *err == NULL, FALSE);

  xr_trace(XR_DEBUG_CLIENT_TRACE, "(conn=%p, uri=%s)", conn, uri);

  // parse URI format: http://host:8080/RES
  g_free(conn->host);
  g_free(conn->resource);
  conn->host = NULL;
  conn->resource = NULL;
  if (!_parse_uri(uri, &conn->secure, &conn->host, &conn->resource))
  {
    g_set_error(err, XR_CLIENT_ERROR, XR_CLIENT_ERROR_FAILED, "invalid URI format: %s", uri);
    return FALSE;
  }

  // enable/disable TLS
  if (conn->secure)
  {
    g_socket_client_set_tls(conn->client, TRUE);
    g_socket_client_set_tls_validation_flags(conn->client, G_TLS_CERTIFICATE_VALIDATE_ALL & ~G_TLS_CERTIFICATE_UNKNOWN_CA & ~G_TLS_CERTIFICATE_BAD_IDENTITY);
  }
  else
  {
    g_socket_client_set_tls(conn->client, FALSE);
  }

  conn->conn = g_socket_client_connect_to_host(conn->client, conn->host, 80, NULL, &local_err);
  if (local_err)
  {
    g_propagate_prefixed_error(err, local_err, "Connection failed: ");
    return FALSE;
  }

  xr_set_nodelay(g_socket_connection_get_socket(conn->conn));

  conn->http = xr_http_new(G_IO_STREAM(conn->conn));
  g_free(conn->session_id);
  conn->session_id = g_strdup_printf("%08x%08x%08x%08x", g_random_int(), g_random_int(), g_random_int(), g_random_int());
  conn->is_open = 1;

  xr_client_set_http_header(conn, "X-SESSION-ID", conn->session_id);

  return TRUE;
}
开发者ID:djdominoSVK,项目名称:libxr,代码行数:51,代码来源:xr-client.c

示例3: ekg_gnutls_new_session

static void ekg_gnutls_new_session(
		GSocketClient *sockclient,
		GSocketConnection *sock,
		struct ekg_connection_starter *cs)
{
	gnutls_session_t s;
	gnutls_certificate_credentials_t cred;
	struct ekg_gnutls_connection *conn = g_slice_new(struct ekg_gnutls_connection);
	struct ekg_gnutls_connection_starter *gcs = g_slice_new(struct ekg_gnutls_connection_starter);

	g_assert(!gnutls_certificate_allocate_credentials(&cred));
	g_assert(!gnutls_init(&s, GNUTLS_CLIENT));
	g_assert(!gnutls_priority_set_direct(s, "PERFORMANCE", NULL)); /* XXX */
	g_assert(!gnutls_credentials_set(s, GNUTLS_CRD_CERTIFICATE, cred));

	gnutls_transport_set_pull_function(s, ekg_gnutls_pull);
	gnutls_transport_set_push_function(s, ekg_gnutls_push);
	gnutls_transport_set_ptr(s, conn);

	gcs->parent = cs;
	gcs->conn = conn;
	gcs->sockclient = sockclient;

	conn->session = s;
	conn->cred = cred;
	conn->connection_error = NULL;
	conn->connection = get_connection_by_outstream(
			ekg_connection_add(
				sock,
				g_io_stream_get_input_stream(G_IO_STREAM(sock)),
				g_io_stream_get_output_stream(G_IO_STREAM(sock)),
				ekg_gnutls_handle_handshake_input,
				ekg_gnutls_handle_handshake_failure,
				gcs)
			);
	g_assert(conn->connection);
	ekg_gnutls_async_handshake(gcs);
}
开发者ID:AdKwiatkos,项目名称:ekg2,代码行数:38,代码来源:connections.c

示例4: handler

static gboolean
handler (GThreadedSocketService *service,
         GSocketConnection      *connection,
         GSocketListener        *listener,
         gpointer                user_data)
{
    GOutputStream *out;
    GInputStream *in;
    char buffer[1024];
    gssize size;

    out = g_io_stream_get_output_stream (G_IO_STREAM (connection));
    in = g_io_stream_get_input_stream (G_IO_STREAM (connection));

    g_output_stream_write_all (out, MESSAGE, strlen (MESSAGE),
                               NULL, NULL, NULL);

    while (0 < (size = g_input_stream_read (in, buffer,
                                            sizeof buffer, NULL, NULL)))
        g_output_stream_write (out, buffer, size, NULL, NULL);

    return TRUE;
}
开发者ID:DreaminginCodeZH,项目名称:glib,代码行数:23,代码来源:echo-server.c

示例5: on_io_closed

static void
on_io_closed (GObject *stream,
              GAsyncResult *result,
              gpointer user_data)
{
  GError *error = NULL;

  if (!g_io_stream_close_finish (G_IO_STREAM (stream), result, &error))
    {
      if (!should_suppress_output_error (error))
        g_message ("http close error: %s", error->message);
      g_error_free (error);
    }
}
开发者ID:briceburg,项目名称:cockpit,代码行数:14,代码来源:cockpitwebserver.c

示例6: onConnection

//------------------------------------------------------------------------------
gboolean onConnection(GSocketService *server,
		      GSocketConnection *connection,
		      GObject *sourceObject,
		      gpointer userData)
{
    g_print("connection\n");
	
    GInputStream *istream = g_io_stream_get_input_stream(G_IO_STREAM(connection));   
    ConnData *data = new ConnData;

    ostream = g_io_stream_get_output_stream(G_IO_STREAM(connection));

    data->connection = (GSocketConnection*)g_object_ref(connection);

    g_input_stream_read_async(istream,
			      data->message,
			      sizeof (data->message),
			      G_PRIORITY_DEFAULT,
			      NULL,
			      onMessage,
			      data);
    return FALSE;
}
开发者ID:j-a-r-i,项目名称:GHwIf,代码行数:24,代码来源:main.cpp

示例7: socket_callback

/* command socket callback */
gboolean socket_callback(GSocketService * service, GSocketConnection * conn,
                         GObject * source_object, gpointer user_data)
{
    video_server_t * server = (video_server_t *)user_data;
    gchar            message[128];
    guint64          value;

    GInputStream * istream = g_io_stream_get_input_stream(G_IO_STREAM(conn));

    g_input_stream_read(istream, message, 128, NULL, NULL);

    /* Supported commands:
     *
     *   "b 5000"     set bitrate to 5 Mbps
     *   "i 3000"     set I-frame interval in msec
     *   "f 30"       set framerate in frames/sec
     *   "s 640x360"  set frame size
     */
    gchar **cmd_str = g_strsplit(message, " ", 0);
    if (g_strv_length(cmd_str) != 2)
    {
        fprintf(stderr, "Incorrect command syntax: %s", message);
        return FALSE;
    }

    switch (cmd_str[0][0])
    {
    case 'b':
        value = g_ascii_strtoull(cmd_str[1], NULL, 0);
        video_server_set_bitrate(server, (unsigned int) value);
        break;
    case 'i':
        value = g_ascii_strtoull(cmd_str[1], NULL, 0);
        video_server_set_iframe_period(server, (unsigned int) value);
        break;
    case 'f':
        value = g_ascii_strtoull(cmd_str[1], NULL, 0);
        video_server_set_framerate(server, (unsigned int) value);
        break;
    case 's':
        get_frame_size(cmd_str[1], server->conf);
        video_server_reset_frame_size(server);
        break;
    }

    g_strfreev(cmd_str);

    return FALSE;
}
开发者ID:DevelopmentWeb,项目名称:bonecam,代码行数:50,代码来源:socket_handler.c

示例8: stream_tube_connection_closed_cb

static void
stream_tube_connection_closed_cb (GObject *source,
    GAsyncResult *result,
    gpointer user_data)
{
  GError *error = NULL;

  if (!g_io_stream_close_finish (G_IO_STREAM (source), result, &error))
    {
      DEBUG ("Failed to close connection: %s", error->message);

      g_error_free (error);
      return;
    }
}
开发者ID:izaackgerard,项目名称:Sintetizador_Voz,代码行数:15,代码来源:stream-tube-channel.c

示例9: connectedCallback

static void connectedCallback(GSocketClient* client, GAsyncResult* result, void* id)
{
    // Always finish the connection, even if this SocketStreamHandle was deactivated earlier.
    GOwnPtr<GError> error;
    GSocketConnection* socketConnection = g_socket_client_connect_to_host_finish(client, result, &error.outPtr());

    // The SocketStreamHandle has been deactivated, so just close the connection, ignoring errors.
    SocketStreamHandle* handle = getHandleFromId(id);
    if (!handle) {
        g_io_stream_close(G_IO_STREAM(socketConnection), 0, &error.outPtr());
        return;
    }

    handle->connected(socketConnection, error.get());
}
开发者ID:0omega,项目名称:platform_external_webkit,代码行数:15,代码来源:SocketStreamHandleSoup.cpp

示例10: seekFile

long long seekFile(PlatformFileHandle handle, long long offset, FileSeekOrigin origin)
{
    GSeekType seekType = G_SEEK_SET;
    switch (origin) {
    case SeekFromBeginning:
        seekType = G_SEEK_SET;
        break;
    case SeekFromCurrent:
        seekType = G_SEEK_CUR;
        break;
    case SeekFromEnd:
        seekType = G_SEEK_END;
        break;
    default:
        ASSERT_NOT_REACHED();
    }

    if (!g_seekable_seek(G_SEEKABLE(g_io_stream_get_input_stream(G_IO_STREAM(handle))),
        offset, seekType, 0, 0))
    {
        return -1;
    }
    return g_seekable_tell(G_SEEKABLE(g_io_stream_get_input_stream(G_IO_STREAM(handle))));
}
开发者ID:caiolima,项目名称:webkit,代码行数:24,代码来源:FileSystemGlib.cpp

示例11: on_io_closed

static void
on_io_closed (GObject *stream,
              GAsyncResult *result,
              gpointer user_data)
{
  GError *error = NULL;

  if (!g_io_stream_close_finish (G_IO_STREAM (stream), result, &error))
    {
      if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_BROKEN_PIPE))
        g_debug ("http close error: %s", error->message);
      else
        g_message ("http close error: %s", error->message);
      g_error_free (error);
    }
}
开发者ID:leospol,项目名称:cockpit,代码行数:16,代码来源:cockpitwebserver.c

示例12: g_tls_client_connection_new

/**
 * g_tls_client_connection_new:
 * @base_io_stream: the #GIOStream to wrap
 * @server_identity: (allow-none): the expected identity of the server
 * @error: #GError for error reporting, or %NULL to ignore.
 *
 * Creates a new #GTlsClientConnection wrapping @base_io_stream (which
 * must have pollable input and output streams) which is assumed to
 * communicate with the server identified by @server_identity.
 *
 * Returns: (transfer full) (type GTlsClientConnection): the new
 * #GTlsClientConnection, or %NULL on error
 *
 * Since: 2.28
 */
GIOStream *
g_tls_client_connection_new (GIOStream           *base_io_stream,
			     GSocketConnectable  *server_identity,
			     GError             **error)
{
  GObject *conn;
  GTlsBackend *backend;

  backend = g_tls_backend_get_default ();
  conn = g_initable_new (g_tls_backend_get_client_connection_type (backend),
			 NULL, error,
			 "base-io-stream", base_io_stream,
			 "server-identity", server_identity,
			 NULL);
  return G_IO_STREAM (conn);
}
开发者ID:QuentinFiard,项目名称:glib,代码行数:31,代码来源:gtlsclientconnection.c

示例13: on_incoming_connection

static gboolean
on_incoming_connection (GSocketService * service,
                        GSocketConnection * connection,
                        GObject * source_object,
                        gpointer user_data)
{
  GInputStream * input;
  void * buf;

  input = g_io_stream_get_input_stream (G_IO_STREAM (connection));
  buf = g_malloc (1);
  g_input_stream_read_async (input, buf, 1, G_PRIORITY_DEFAULT, NULL,
      on_read_ready, NULL);

  return TRUE;
}
开发者ID:luiseduardohdbackup,项目名称:frida-gum,代码行数:16,代码来源:script.c

示例14: g_tls_server_connection_new

/**
 * g_tls_server_connection_new:
 * @base_io_stream: the #GIOStream to wrap
 * @certificate: (allow-none): the default server certificate, or %NULL
 * @error: #GError for error reporting, or %NULL to ignore.
 *
 * Creates a new #GTlsServerConnection wrapping @base_io_stream (which
 * must have pollable input and output streams).
 *
 * Return value: (transfer full): the new #GTlsServerConnection, or %NULL on error
 *
 * Since: 2.28
 */
GIOStream *
g_tls_server_connection_new (GIOStream        *base_io_stream,
			     GTlsCertificate  *certificate,
			     GError          **error)
{
  GObject *conn;
  GTlsBackend *backend;

  backend = g_tls_backend_get_default ();
  conn = g_initable_new (g_tls_backend_get_server_connection_type (backend),
			 NULL, error,
			 "base-io-stream", base_io_stream,
			 "certificate", certificate,
			 NULL);
  return G_IO_STREAM (conn);
}
开发者ID:BreakawayConsulting,项目名称:glib,代码行数:29,代码来源:gtlsserverconnection.c

示例15: gum_duk_debug_channel_add_session

static void
gum_duk_debug_channel_add_session (GumDukDebugChannel * self,
                                   GSocketConnection * connection)
{
  gboolean is_first_session;
  GumDukDebugSession * session;

  is_first_session = self->sessions == NULL;

  session = gum_duk_debug_session_new (self, G_IO_STREAM (connection));
  self->sessions = g_slist_prepend (self->sessions, session);

  gum_duk_debug_session_open (session);

  if (is_first_session)
    gum_duk_debug_channel_attach (self);
}
开发者ID:aonorin,项目名称:frida-gum,代码行数:17,代码来源:script-dukdebugserver.c


注:本文中的G_IO_STREAM函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。