diff options
author | linus <linus@nordu.net> | 2011-01-21 16:32:28 +0100 |
---|---|---|
committer | linus <linus@nordu.net> | 2011-01-21 16:32:28 +0100 |
commit | f58ce3d98a13e9c8d0930b54c5f593cbfa196d65 (patch) | |
tree | f20db3c05fa49c3b9ddad748b8a0b9dc6c79404f /lib/tests/test-blocking.c | |
parent | 7b928a0509a668b99679a1bbedd189575fe71559 (diff) |
Some more UDP tests.
Diffstat (limited to 'lib/tests/test-blocking.c')
-rw-r--r-- | lib/tests/test-blocking.c | 64 |
1 files changed, 0 insertions, 64 deletions
diff --git a/lib/tests/test-blocking.c b/lib/tests/test-blocking.c deleted file mode 100644 index e1f657b..0000000 --- a/lib/tests/test-blocking.c +++ /dev/null @@ -1,64 +0,0 @@ -#include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <netdb.h> -#include <stdio.h> -#include <stdlib.h> -#include "blocking.h" - -int -f (const struct sockaddr *addr, - socklen_t addrlen, - int out_fd) -{ - int fd = -1; - //struct rs_alloc_scheme as = { calloc, malloc, free, realloc }; - struct rs_handle ctx = { RS_CONN_TYPE_TCP, - { RS_CRED_NONE, NULL, NULL }, - { NULL, NULL, NULL, NULL } }; - struct rs_packet *p = NULL; - - fd = rs_connect (&ctx, addr, addrlen); - if (fd < 0) - { - perror ("rs_connect"); - return -1; - } - - p = next_packet (&ctx, fd); - if (p == NULL) - { - perror ("next_packet"); - rs_disconnect (&ctx, fd); - return -1; - } - rs_disconnect (&ctx, fd); - - if (send_packet (&ctx, out_fd, p)) - { - rs_packet_free (&ctx, &p); - perror ("send_packet"); - return -1; - } - - return 0; -} - -int -main (int argc, char *argv[]) -{ - struct addrinfo *ai; - int rc; - - rc = getaddrinfo (argv[1], argv[2], NULL, &ai); - if (rc) - { - if (rc == EAI_SYSTEM) - perror ("getaddrinfo"); - else - fprintf (stderr, "getaddrinfo: %s\n", gai_strerror (rc)); - return -1; - } - - return f (ai->ai_addr, ai->ai_addrlen, 1); -} |