Subject | Hash | Author | Date (UTC) |
---|---|---|---|
Added xbind example. | 1cdf8e8fd7ba9049eafef8f136d6b4e5e870b0ff | Catalin(ux) M. BOIE | 2009-12-30 22:37:01 |
TODO in/out. | b0d7ba7f8abe58861a47586d767ff35bc1f0961d | Catalin(ux) M. BOIE | 2009-12-30 22:35:55 |
Stop Conn if nothing to do. | 7f13d71774792aa97b341a2e69bb557d15b6c74a | Catalin(ux) M. BOIE | 2009-12-06 01:38:12 |
Improved Conn_split_* and removed a bad leak! | f47f85c65ac5781d9419b58b20db632772947c64 | Catalin(ux) M. BOIE | 2009-12-06 01:24:58 |
Bump up the version. | 4788a6979d84939cc7aaf824ef8e0b7357cab6cc | Catalin(ux) M. BOIE | 2009-12-07 12:50:16 |
Duilder updates. | 1b717c718189468006ff0e7fb228571e76fb97e6 | Catalin(ux) M. BOIE | 2009-12-07 12:49:55 |
Exported Conn_engine_set function. | 1c69de5306d302fcd6b3e6351d3e28771b08bb05 | Catalin(ux) M. BOIE | 2009-11-12 15:18:40 |
Bumped up the version to 1.0.29. | ee219d6016983a64187cfe0866c597419f464535 | Catalin(ux) M. BOIE | 2009-09-18 12:07:41 |
Fix Conn_poll(-1)! Stupid me! | 4ce77092baec7cbbfcd8d943838aa7eeefedbc8e | Catalin(ux) M. BOIE | 2009-09-18 12:07:04 |
Bump up the version to 1.0.28. | deea1515d967c7b0708e25fe146799a09c5c2dc8 | Catalin(ux) M. BOIE | 2009-09-18 11:15:46 |
Do poll in 1000ms steps, even if Conn_poll is called with != 1 value. Else, triggers are not called! | 59b4d5d8db5a4a9048f61ad836e67c824bb1ac95 | Catalin(ux) M. BOIE | 2009-09-18 11:15:04 |
Bumbed up the version to 1.0.27. | 62ffc3a45094bd4b2d345d7ba37c862e1605050c | Catalin(ux) M. BOIE | 2009-09-18 09:43:03 |
More clear what error message is. | acd5309c8de872f618a1055258614cf542dadf51 | Catalin(ux) M. BOIE | 2009-09-18 09:42:38 |
Compact totals. | e85a25c33e9f716317932b6ee7f4b3ae6c459ff9 | Catalin(ux) M. BOIE | 2009-09-18 09:37:19 |
Cosmetic changes. | 14da1b82e17275b6869493fa15e931536b77e547 | Catalin(ux) M. BOIE | 2009-09-18 09:31:23 |
Log also how many pending connections are after trytoconnect call. | 4cd341f53a426cb49e437a46388b586913c0c859 | Catalin(ux) M. BOIE | 2009-09-18 09:30:47 |
Bumped up the version to 1.0.26. | 2c68c221bf5ef3f5a0779e94c0448231b9fd630f | Catalin(ux) M. BOIE | 2009-09-18 08:31:14 |
Fixed a bug regarding work_to_do (decrementing on bind errors). | 8b8585685bdd07d0e1df9a7ca9e41ecca9cc73bf | Catalin(ux) M. BOIE | 2009-09-18 08:30:10 |
Log also commit function. | c920c0191bebc71b18bc318803db7f02ddc7b77f | Catalin(ux) M. BOIE | 2009-09-18 08:21:53 |
Log also work_to_do. | a7c800b63e6ca4384726c7269e097c4f76f9991e | Catalin(ux) M. BOIE | 2009-09-18 07:51:26 |
File | Lines added | Lines deleted |
---|---|---|
examples/Makefile | 5 | 1 |
examples/xbind.c | 79 | 0 |
File examples/Makefile changed (mode: 100644) (index 69775e7..50ff55e) | |||
1 | TARGETS := s c raw udp_s timeout trigger reconnect ntime blackhole_s blackhole_c test1 | ||
1 | TARGETS := s c raw udp_s timeout trigger reconnect ntime blackhole_s blackhole_c \ | ||
2 | xbind | ||
2 | 3 | ||
3 | 4 | all: $(TARGETS) | all: $(TARGETS) |
4 | 5 | ||
... | ... | blackhole_c: blackhole_c.c $(DEPS) | |
43 | 44 | test1: test1.c $(DEPS) | test1: test1.c $(DEPS) |
44 | 45 | gcc $(CFLAGS) $(INCS) $@.c -o $@ $(LIBS) -lrt | gcc $(CFLAGS) $(INCS) $@.c -o $@ $(LIBS) -lrt |
45 | 46 | ||
47 | xbind: xbind.c $(DEPS) | ||
48 | gcc $(CFLAGS) $(INCS) $@.c -o $@ $(LIBS) | ||
49 | |||
46 | 50 | %: %.c $(DEPS) | %: %.c $(DEPS) |
47 | 51 | gcc $(CFLAGS) $(INCS) $@.c -o $@ $(LIBS) | gcc $(CFLAGS) $(INCS) $@.c -o $@ $(LIBS) |
48 | 52 |
File examples/xbind.c added (mode: 100644) (index 0000000..ebc2c79) | |||
1 | #define _GNU_SOURCE | ||
2 | |||
3 | #include <errno.h> | ||
4 | #include <string.h> | ||
5 | #include <strings.h> | ||
6 | #include <stdlib.h> | ||
7 | #include <unistd.h> | ||
8 | #include <sys/poll.h> | ||
9 | #include <sys/types.h> | ||
10 | #include <sys/socket.h> | ||
11 | #include <stdio.h> | ||
12 | #include <fcntl.h> | ||
13 | #include <netinet/in.h> | ||
14 | #include <sys/time.h> | ||
15 | #include <sys/ioctl.h> | ||
16 | #include <time.h> | ||
17 | #include <arpa/inet.h> | ||
18 | #include <stdarg.h> | ||
19 | |||
20 | #include <Conn.h> | ||
21 | |||
22 | /* Global variables */ | ||
23 | static unsigned short debug = 20; | ||
24 | |||
25 | static FILE *Logf = NULL; | ||
26 | static char *log_file = "xbind.log"; | ||
27 | |||
28 | static void s_error(struct Conn *C) | ||
29 | { | ||
30 | Log(1, "%s id=%llu (%s)\n", | ||
31 | __FUNCTION__, Conn_getid(C), Conn_strerror()); | ||
32 | } | ||
33 | |||
34 | int main(void) | ||
35 | { | ||
36 | struct Conn *C; | ||
37 | int ret, i, family, protocol; | ||
38 | char *addr; | ||
39 | |||
40 | Logf = fopen(log_file, "w"); | ||
41 | if (!Logf) { | ||
42 | fprintf(stderr, "Cannot open log file [%s] [%s]\n", | ||
43 | log_file, strerror(errno)); | ||
44 | return 1; | ||
45 | } | ||
46 | if (debug > 0) | ||
47 | setlinebuf(Logf); | ||
48 | |||
49 | /* set library output debug */ | ||
50 | Conn_debug(Logf, debug); | ||
51 | |||
52 | ret = Conn_init(0); | ||
53 | if (ret == -1) { | ||
54 | Log(0, "%s", Conn_strerror()); | ||
55 | return 1; | ||
56 | } | ||
57 | |||
58 | Conn_error_cb = s_error; | ||
59 | |||
60 | addr = "200.200.200.200"; | ||
61 | family = Conn_addr_family(addr); | ||
62 | protocol = SOCK_STREAM; | ||
63 | |||
64 | i = 0; | ||
65 | while (i++ < 100) { | ||
66 | C = Conn_socket_addr(family, protocol, addr, 65533); | ||
67 | if (!C) { | ||
68 | Log(0, "Cannot bind!\n"); | ||
69 | continue; | ||
70 | } | ||
71 | Conn_close(C); | ||
72 | } | ||
73 | |||
74 | Conn_shutdown(); | ||
75 | |||
76 | Log(0, "Finish!\n\n"); | ||
77 | |||
78 | return 0; | ||
79 | } |