GMainLoop *loop;
-/*
-void
-accept_callback (GSocket *socket, GAsyncResult *result, gpointer data)
+static void
+connect_callback (GObject *source, GAsyncResult *result, gpointer data)
{
+ GTcpClient *client = G_TCP_CLIENT (source);
GError *error = NULL;
- if (!g_socket_connect_finish (socket, result, &error)) {
+ if (!g_tcp_client_connect_finish (client, result, &error)) {
g_warning (error->message);
return;
}
g_print ("successfully connected\n");
}
-*/
int main (int argc, char *argv[])
{
GTcpClient *client;
- GInputStream *input;
+/* GInputStream *input;
GOutputStream *output;
- GError *error = NULL;
gchar buffer[512] = {0};
gssize count;
+ GError *error = NULL;*/
g_thread_init (NULL);
loop = g_main_loop_new (NULL, FALSE);
- client = g_tcp_client_new ("www.google.com", 80);
+ client = g_tcp_client_new ("localhost", 80);
g_print ("connecting to www.google.com:80\n");
+ g_tcp_client_connect_async (client, NULL, connect_callback, NULL);
+
+ g_print ("connecting seems to have begun\n");
+/*
if (!g_tcp_client_connect (client, NULL, &error)) {
g_warning (error->message);
return 1;
g_print ("read %d bytes: %s\n", count, buffer);
g_object_unref (G_OBJECT (client));
-
-// g_main_loop_run (loop);
+*/
+ g_main_loop_run (loop);
return 0;
}