TcpClient seems to be working for sync connects, but connect()
[cascardo/gnio.git] / test / test-tcp-client.c
1 #include <gio/gio.h>
2 #include <gnio/gnio.h>
3
4 GMainLoop *loop;
5
6 /*
7 void
8 accept_callback (GSocket *socket, GAsyncResult *result, gpointer data)
9 {
10         GError *error = NULL;
11
12         if (!g_socket_connect_finish (socket, result, &error)) {
13                 g_warning (error->message);
14                 return;
15         }
16
17         g_print ("successfully connected\n");
18 }
19 */
20
21 int main (int argc, char *argv[])
22 {
23         GTcpClient *client;
24         GError *error = NULL;
25
26         g_thread_init (NULL);
27
28         g_type_init ();
29
30         loop = g_main_loop_new (NULL, FALSE);
31
32         client = g_tcp_client_new ("localhost", 90);
33
34         g_print ("connecting to www.google.com:80\n");
35
36         if (!g_tcp_client_connect (client, NULL, &error)) {
37                 g_warning (error->message);
38                 return;
39         }
40
41         g_print ("connected!\n");
42
43         g_object_unref (G_OBJECT (client));
44
45 //      g_main_loop_run (loop);
46
47         return 0;
48 }