• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ G_IO_STREAM函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: jetdirect_connection_test_cb

static void
jetdirect_connection_test_cb (GObject      *source_object,
                              GAsyncResult *res,
                              gpointer      user_data)
{
  GSocketConnection *connection;
  PpHostPrivate     *priv;
  PpPrintDevice     *device;
  JetDirectData     *data;
  gpointer           result;
  GError            *error = NULL;
  GTask             *task = G_TASK (user_data);

  data = g_task_get_task_data (task);

  connection = g_socket_client_connect_to_host_finish (G_SOCKET_CLIENT (source_object),
                                                       res,
                                                       &error);

  if (connection != NULL)
    {
      g_io_stream_close (G_IO_STREAM (connection), NULL, NULL);
      g_object_unref (connection);

      priv = data->host->priv;

      device = g_new0 (PpPrintDevice, 1);
      device->device_class = g_strdup ("network");
      device->device_uri = g_strdup_printf ("socket://%s:%d",
                                            priv->hostname,
                                            data->port);
      /* Translators: The found device is a JetDirect printer */
      device->device_name = g_strdup (_("JetDirect Printer"));
      device->host_name = g_strdup (priv->hostname);
      device->host_port = data->port;
      device->acquisition_method = ACQUISITION_METHOD_JETDIRECT;

      data->devices->devices = g_list_append (data->devices->devices, device);
    }

  result = data->devices;
  data->devices = NULL;
  g_task_return_pointer (task, result, (GDestroyNotify) pp_devices_list_free);
  g_object_unref (task);
}
开发者ID:1dot75cm,项目名称:gnome-control-center,代码行数:45,代码来源:pp-host.c


示例17: identd_incoming_cb

static gboolean
identd_incoming_cb (GSocketService *service, GSocketConnection *conn,
                    GObject *source, gpointer userdata)
{
    GInputStream *stream;
    ident_info *info;

    info = g_new0 (ident_info, 1);

    info->conn = conn;
    g_object_ref (conn);

    stream = g_io_stream_get_input_stream (G_IO_STREAM (conn));
    g_input_stream_read_async (stream, info->read_buf, sizeof (info->read_buf), G_PRIORITY_DEFAULT,
                               NULL, (GAsyncReadyCallback)identd_read_ready, info);

    return TRUE;
}
开发者ID:HextorIRC,项目名称:hextor,代码行数:18,代码来源:plugin-identd.c


示例18: g_vfs_ftp_connection_open_data_connection

gboolean
g_vfs_ftp_connection_open_data_connection (GVfsFtpConnection *conn,
                                           GSocketAddress *   addr,
                                           GCancellable *     cancellable,
                                           GError **          error)
{
  g_return_val_if_fail (conn != NULL, FALSE);
  g_return_val_if_fail (conn->data == NULL, FALSE);

  g_vfs_ftp_connection_stop_listening (conn);

  conn->data = G_IO_STREAM (g_socket_client_connect (conn->client,
                                                     G_SOCKET_CONNECTABLE (addr),
                                                     cancellable,
                                                     error));

  return conn->data != NULL;
}
开发者ID:BATYakhkhkh,项目名称:gvfs,代码行数:18,代码来源:gvfsftpconnection.c


示例19: main

int
main (int argc, char *argv[])
{
   /* initialize glib */
  //g_type_init ();

  GError * error = NULL;

  /* create a new connection */
  GSocketConnection * connection = NULL;
  GSocketClient * client = g_socket_client_new();

  /* connect to the host */
  connection = g_socket_client_connect_to_host (client,
                                               (gchar*)"localhost",
                                                2345, /* your port goes here */
                                                NULL,
                                                &error);

  /* don't forget to check for errors */
  if (error != NULL)
  {
      g_error (error->message);
  }
  else
  {
      g_print ("Connection successful!\n");
  }

  /* use the connection */
  //GInputStream * istream = g_io_stream_get_input_stream (G_IO_STREAM (connection));
  GOutputStream * ostream = g_io_stream_get_output_stream (G_IO_STREAM (connection));
  g_output_stream_write  (ostream,
                          "Hello server!", /* your message goes here */
                          13, /* length of your message */
                          NULL,
                          &error);
  /* don't forget to check for errors */
  if (error != NULL)
  {
      g_error (error->message);
  }
  return 0;
}
开发者ID:unclejamil,项目名称:glib-cookbook,代码行数:44,代码来源:gio_simple_client.c


示例20: zpj_download_stream_ready

static void
zpj_download_stream_ready (GObject *source,
                       GAsyncResult *res,
                       gpointer user_data)
{
  GError *error = NULL;
  PdfLoadJob *job = (PdfLoadJob *) user_data;
  const gchar *name;
  const gchar *extension;

  job->stream = zpj_skydrive_download_file_to_stream_finish (ZPJ_SKYDRIVE (source), res, &error);
  if (error != NULL) {
    pdf_load_job_complete_error (job, error);
    return;
  }

  name = zpj_skydrive_entry_get_name (job->zpj_entry);
  extension = gd_filename_get_extension_offset (name);

  /* If it is not a PDF, we need to convert it afterwards.
   * http://msdn.microsoft.com/en-us/library/live/hh826545#fileformats
   */
  if (g_strcmp0 (extension, ".pdf") != 0)
    {
      GFileIOStream *iostream;

      job->download_file = g_file_new_tmp (NULL, &iostream, &error);
      if (error != NULL) {
        pdf_load_job_complete_error (job, error);
        return;
      }

      /* We don't need the iostream. */
      g_io_stream_close (G_IO_STREAM (iostream), NULL, NULL);
    }
  else
    job->download_file = g_file_new_for_path (job->pdf_path);

  g_file_replace_async (job->download_file, NULL, FALSE,
                        G_FILE_CREATE_PRIVATE,
                        G_PRIORITY_DEFAULT,
                        job->cancellable, file_replace_ready_cb,
                        job);
}
开发者ID:TiredFingers,项目名称:gnome-documents,代码行数:44,代码来源:gd-pdf-loader.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ G_IS_APP_INFO函数代码示例发布时间:2022-05-30
下一篇:
C++ G_INPUT_STREAM函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap