Annotation of libaitio/example/test_n2.c, revision 1.2.6.3
1.2 misho 1: #include <stdio.h>
1.2.6.1 misho 2: #include <string.h>
1.2 misho 3: #include <aitio.h>
4:
5:
6: int
7: main(int argc, char **argv)
8: {
9: io_sockaddr_t addr = { 0 };
1.2.6.1 misho 10: ait_val_t v, *val = NULL;
11:
12: AIT_SET_DATA(val, "shits hit the fan! --- shits with Merudia ...\n", 47);
13: printf("GET DATA = %p %s t=%d l=%d\n", val, AIT_GET_DATA(val), AIT_TYPE(val), AIT_LEN(val));
1.2.6.2 misho 14: AIT_SET_DATA(val, argv[1], strlen(argv[1]) + 1);
15: AIT_FREE_VAL(val);
16: AIT_SET_DATA(val, argv[1], strlen(argv[1]) + 1);
17: printf("GET DATA = %p %s t=%d l=%d\n", val, AIT_GET_DATA(val), AIT_TYPE(val), AIT_LEN(val));
1.2.6.1 misho 18: AIT_FREE_VAL(val);
1.2 misho 19:
20: if (!io_gethostbyname(argv[1], 1234, &addr)) {
21: printf("Error:: #%d - %s\n", io_GetErrno(), io_GetError());
22: return 1;
23: }
24:
25: if (!io_n2addr(&addr, &v)) {
26: printf("Error:: #%d - %s\n", io_GetErrno(), io_GetError());
27: return 2;
28: }
29:
30: printf("Address is %s port is %u\n", AIT_GET_STR(&v), io_n2port(&addr));
31:
32: AIT_FREE_VAL(&v);
33: return 0;
34: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>