diff options
author | Nils Durner <durner@gnunet.org> | 2009-08-23 22:11:49 +0000 |
---|---|---|
committer | Nils Durner <durner@gnunet.org> | 2009-08-23 22:11:49 +0000 |
commit | 2518cfc0a86865ebe4d0550e0013ed52a494231b (patch) | |
tree | e9a130b782597e18bcff24a9fdab6e5c6aae1f9c /src/util/test_network_addressing.c | |
parent | 2ae973618f3b51fa9bbf5532eaa1352cafc24ecc (diff) | |
download | gnunet-2518cfc0a86865ebe4d0550e0013ed52a494231b.tar.gz gnunet-2518cfc0a86865ebe4d0550e0013ed52a494231b.zip |
low level network API
Diffstat (limited to 'src/util/test_network_addressing.c')
-rw-r--r-- | src/util/test_network_addressing.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/util/test_network_addressing.c b/src/util/test_network_addressing.c index aeb187634..a2682a733 100644 --- a/src/util/test_network_addressing.c +++ b/src/util/test_network_addressing.c | |||
@@ -23,7 +23,7 @@ | |||
23 | */ | 23 | */ |
24 | #include "platform.h" | 24 | #include "platform.h" |
25 | #include "gnunet_common.h" | 25 | #include "gnunet_common.h" |
26 | #include "gnunet_network_lib.h" | 26 | #include "gnunet_connection_lib.h" |
27 | #include "gnunet_scheduler_lib.h" | 27 | #include "gnunet_scheduler_lib.h" |
28 | #include "gnunet_time_lib.h" | 28 | #include "gnunet_time_lib.h" |
29 | 29 | ||
@@ -40,32 +40,32 @@ static struct GNUNET_NETWORK_ConnectionHandle *lsock; | |||
40 | 40 | ||
41 | static size_t sofar; | 41 | static size_t sofar; |
42 | 42 | ||
43 | static int ls; | 43 | static struct GNUNET_NETWORK_Descriptor *ls; |
44 | 44 | ||
45 | 45 | ||
46 | 46 | ||
47 | /** | 47 | /** |
48 | * Create and initialize a listen socket for the server. | 48 | * Create and initialize a listen socket for the server. |
49 | * | 49 | * |
50 | * @return -1 on error, otherwise the listen socket | 50 | * @return NULL on error, otherwise the listen socket |
51 | */ | 51 | */ |
52 | static int | 52 | static struct GNUNET_NETWORK_Descriptor * |
53 | open_listen_socket () | 53 | open_listen_socket () |
54 | { | 54 | { |
55 | const static int on = 1; | 55 | const static int on = 1; |
56 | struct sockaddr_in sa; | 56 | struct sockaddr_in sa; |
57 | int fd; | 57 | struct GNUNET_NETWORK_Descriptor *desc; |
58 | 58 | ||
59 | memset (&sa, 0, sizeof (sa)); | 59 | memset (&sa, 0, sizeof (sa)); |
60 | sa.sin_port = htons (PORT); | 60 | sa.sin_port = htons (PORT); |
61 | fd = SOCKET (AF_INET, SOCK_STREAM, 0); | 61 | desc = GNUNET_NETWORK_socket_socket (AF_INET, SOCK_STREAM, 0); |
62 | GNUNET_assert (fd >= 0); | 62 | GNUNET_assert (desc != 0); |
63 | if (SETSOCKOPT (fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) < 0) | 63 | if (GNUNET_NETWORK_socket_setsockopt (desc, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) < 0) |
64 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 64 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |
65 | "setsockopt"); | 65 | "setsockopt"); |
66 | GNUNET_assert (BIND (fd, &sa, sizeof (sa)) >= 0); | 66 | GNUNET_assert (GNUNET_NETWORK_socket_bind (desc, &sa, sizeof (sa)) >= 0); |
67 | LISTEN (fd, 5); | 67 | GNUNET_NETWORK_socket_listen (desc, 5); |
68 | return fd; | 68 | return desc; |
69 | } | 69 | } |
70 | 70 | ||
71 | 71 | ||
@@ -156,7 +156,7 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
156 | GNUNET_TIME_UNIT_SECONDS, | 156 | GNUNET_TIME_UNIT_SECONDS, |
157 | &make_hello, NULL)); | 157 | &make_hello, NULL)); |
158 | GNUNET_NETWORK_connection_destroy (csock); | 158 | GNUNET_NETWORK_connection_destroy (csock); |
159 | GNUNET_SCHEDULER_add_read (tc->sched, | 159 | GNUNET_SCHEDULER_add_read_net (tc->sched, |
160 | GNUNET_NO, | 160 | GNUNET_NO, |
161 | GNUNET_SCHEDULER_PRIORITY_HIGH, | 161 | GNUNET_SCHEDULER_PRIORITY_HIGH, |
162 | GNUNET_SCHEDULER_NO_TASK, | 162 | GNUNET_SCHEDULER_NO_TASK, |