void           remote_client_connect          (RemoteClient*         self)
{
    /* Clean up after the previous connection, if we need to */
    if (self->gconn) {
	gnet_conn_delete(self->gconn);
	self->gconn = NULL;
    }
    remote_client_empty_queue(self);

    /* Reset our speed counters and rate limiting timers */
    self->iter_accumulator = 0;
    self->byte_accumulator = 0;
    self->iters_per_sec = 0;
    self->bytes_per_sec = 0;
    g_timer_start(self->stream_request_timer);
    g_timer_start(self->status_speed_timer);
    g_timer_start(self->stream_speed_timer);

    /* Create the new connection object */
    self->gconn = gnet_conn_new(self->host, self->port, remote_client_callback, self);
    gnet_conn_set_watch_error(self->gconn, TRUE);
    gnet_conn_connect(self->gconn);
    gnet_conn_readline(self->gconn);

    remote_client_update_status(self, "Connecting...");
}
Esempio n. 2
0
int main (int argc, char** argv)
{
    gchar* hostname;
    gint port;
    GMainLoop* main_loop;
    GConn* conn;

    gnet_init ();

    /* Parse args */
    if (argc != 4)
    {
        g_print ("usage: %s <server> <port> <output-directory>\n", argv[0]);
        exit(EXIT_FAILURE);
    }
    hostname = argv[1];
    port = atoi(argv[2]);
    out_dir = argv[3];
    check_dir (out_dir);
    update_filename ();

    /* Create the main loop */
    main_loop = g_main_new(FALSE);

    /* Create connection object */
    conn = gnet_conn_new (hostname, port, ob_conn_func, NULL);
    g_assert (conn);

    /* Connect */
    gnet_conn_connect (conn);
    gnet_conn_set_watch_error (conn, TRUE);
    gnet_conn_timeout (conn, 30000);  /* 30 second timeout */

    //open the xml file
    init_xml ();
    atexit (flush_xml);

    /* Start the main loop */
    g_main_run (main_loop);

    exit (EXIT_SUCCESS);
    return 0;
}
Esempio n. 3
0
int
main(int argc, char** argv)
{
  gchar* hostname;
  gint port;
  GMainLoop* main_loop;
  GConn* conn;
  GIOChannel* in;

  gnet_init ();

  /* Parse args */
  if (argc != 3)
    {
      g_print ("usage: %s <server> <port>\n", argv[0]);
      exit(EXIT_FAILURE);
    }
  hostname = argv[1];
  port = atoi(argv[2]);

  /* Create the main loop */
  main_loop = g_main_new(FALSE);
  
  /* Create connection object */
  conn = gnet_conn_new (hostname, port, ob_conn_func, NULL);
  g_assert (conn);

  /* Connect */
  gnet_conn_connect (conn);
  gnet_conn_set_watch_error (conn, TRUE);
  gnet_conn_timeout (conn, 30000);  /* 30 second timeout */

  /* Read from stdin */
  in = g_io_channel_unix_new (fileno(stdin));
  g_io_add_watch(in, G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL, 
		 ob_in_iofunc, conn);

  /* Start the main loop */
  g_main_run (main_loop);

  exit (EXIT_SUCCESS);
  return 0;
}