projects
/
cascardo
/
gnio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Async connecting *almost* works. For some reason the G_IO_OUT condition
[cascardo/gnio.git]
/
test
/
test-tcp-client.c
diff --git
a/test/test-tcp-client.c
b/test/test-tcp-client.c
index
467d172
..
8620ba4
100644
(file)
--- a/
test/test-tcp-client.c
+++ b/
test/test-tcp-client.c
@@
-3,29
+3,28
@@
GMainLoop *loop;
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;
GError *error = NULL;
- if (!g_
socket_connect_finish (socke
t, result, &error)) {
+ if (!g_
tcp_client_connect_finish (clien
t, result, &error)) {
g_warning (error->message);
return;
}
g_print ("successfully connected\n");
}
g_warning (error->message);
return;
}
g_print ("successfully connected\n");
}
-*/
int main (int argc, char *argv[])
{
GTcpClient *client;
int main (int argc, char *argv[])
{
GTcpClient *client;
-
GInputStream *input;
+
/*
GInputStream *input;
GOutputStream *output;
GOutputStream *output;
- GError *error = NULL;
gchar buffer[512] = {0};
gssize count;
gchar buffer[512] = {0};
gssize count;
+ GError *error = NULL;*/
g_thread_init (NULL);
g_thread_init (NULL);
@@
-33,10
+32,14
@@
int main (int argc, char *argv[])
loop = g_main_loop_new (NULL, FALSE);
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_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;
if (!g_tcp_client_connect (client, NULL, &error)) {
g_warning (error->message);
return 1;
@@
-65,8
+68,8
@@
int main (int argc, char *argv[])
g_print ("read %d bytes: %s\n", count, buffer);
g_object_unref (G_OBJECT (client));
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;
}
return 0;
}