catalinux / Conn (public) (License: LGPLv2) (since 2016-03-01) (hash sha1)
Net library for easy building ipv4/ipv6 network daemons/clients
List of commits:
Subject Hash Author Date (UTC)
Improved blackhole examples. 128f393aba2b07c4aa0e41d962a8239dffc3cc10 Catalin(ux) M. BOIE 2009-08-31 17:41:30
More entries to .gitignore. e1d71bcf46a9b61a4aa4e17b857ff9035d7fb6c7 Catalin(ux) M. BOIE 2009-08-31 17:39:45
Tweaked a little the debug level for some messages. 1a27a1acf2ede62fb02b074f232badeb847bfcb8 Catalin(ux) M. BOIE 2009-08-31 17:39:21
Added Conn_lifetime (returns the time in ms between connected state and now). 4e3f1aaabc21d4cbdac26e42612ebd0298c8d86e Catalin(ux) M. BOIE 2009-08-31 17:22:37
Added Conn_sys that logs some system variables related to network perf. af960f317b8ca9a8f78fe44e80ddbdb6a9483e6f Catalin(ux) M. BOIE 2009-08-31 16:36:00
Better output flags. d57a98c2b158aeb30530c2e5188977a40336a360 Catalin(ux) M. BOIE 2009-08-25 20:37:55
Improved examples. 75439293c1d067327e606d72ec6290b43110bf24 Catalin(ux) M. BOIE 2009-08-25 20:37:29
Removed line1.c because duplicates code. 1119059afacde8d0b7b7dab77850dd6b71684190 Catalin(ux) M. BOIE 2009-08-25 20:11:52
Removed *.run becasue we have a generic run script. 007083cd9d1abefe4dd73e65c9026a2607fbcd4e Catalin(ux) M. BOIE 2009-08-25 20:09:00
Removed bind_s example because blackhole_s will take place. b9b06d98f00413b5a5df9d7bc9b3bd05b5536f28 Catalin(ux) M. BOIE 2009-08-25 20:07:38
Added Conn_set_address helper. 1b6e7e8a294ac88aa966e4e43bb77a4fdff0ca5a Catalin(ux) M. BOIE 2009-08-25 19:21:00
Fixed storing of local address (do not overwrite remote address). d431edba6699d1363e4d616aa6f96588272188b0 Catalin(ux) M. BOIE 2009-08-25 18:37:55
Added Conn_stop to eleganly stop Conn system. 4ca191771c5c119e9755a5af3158fabe43ddf5f2 Catalin(ux) M. BOIE 2009-08-25 18:30:32
Replaced Conn_protocol with Conn_get_socket_protocol. a1cbc5c612d82e6d1341524c67fe249648c81806 Catalin(ux) M. BOIE 2009-08-25 18:16:45
Compressed a little the POLL flags. 47b5dce395694c18c973e3ce6ba9a71c690a41bc Catalin(ux) M. BOIE 2009-08-25 18:16:16
Store also local address for incoming connections. 0548ce6434185cdd36e110c61315b4cb21849666 Catalin(ux) M. BOIE 2009-08-25 18:15:46
Added possibility to shutdown blackhole_s server by typing 'quit'. 5fd60900809e1a2d7554aa7fa93ce83b29214de0 Catalin(ux) M. BOIE 2009-08-25 17:54:27
Cosmetic changes. 7099dd49a270b9f4ecc0cb2e55254bef671202e5 Catalin(ux) M. BOIE 2009-08-25 17:54:15
Improved status output. 1ff597059bbb208b56ad18bf8324fae5b63950a2 Catalin(ux) M. BOIE 2009-08-25 17:53:44
Conn_type_* becomes CONN_TYPE_*. b284a20cc5430042cc662edc4d121c7f18cb3569 Catalin(ux) M. BOIE 2009-08-25 17:52:51
Commit 128f393aba2b07c4aa0e41d962a8239dffc3cc10 - Improved blackhole examples.
Signed-off-by: Catalin(ux) M. BOIE <catab@embedromix.ro>
Author: Catalin(ux) M. BOIE
Author date (UTC): 2009-08-31 17:41
Committer name: Catalin(ux) M. BOIE
Committer date (UTC): 2009-09-02 15:42
Parent(s): e1d71bcf46a9b61a4aa4e17b857ff9035d7fb6c7
Signing key:
Tree: 942a5f43beec647588ddee27f5e4de0eb4d8fc5f
File Lines added Lines deleted
examples/blackhole_c.c 20 7
examples/blackhole_s.c 11 8
File examples/blackhole_c.c changed (mode: 100644) (index 09a2b10..5263dea)
7 7 #include <Conn.h> #include <Conn.h>
8 8
9 9 /* Global variables */ /* Global variables */
10 static unsigned short debug = 20;
11 static unsigned int ipv4conns = 3, ipv6conns = 3;
12
10 static unsigned short debug = 9;
11 static unsigned int ipv4conns = 1000, ipv6conns = 0;
13 12 static int port = 9000; static int port = 9000;
13 static unsigned int buf_size = 4096 * 10;
14
14 15 static unsigned int ends = 0; static unsigned int ends = 0;
15 16 static unsigned char *buf; static unsigned char *buf;
16 static int buf_size;
17 17 static unsigned long long errors = 0; static unsigned long long errors = 0;
18 18 static unsigned long long bytes = 0; static unsigned long long bytes = 0;
19 static unsigned long long latency = 0;
19 20
20 21
21 22 static void c_connected(struct Conn *C) static void c_connected(struct Conn *C)
 
... ... static void c_error(struct Conn *C)
40 41 errors++; errors++;
41 42 } }
42 43
44 static void c_close(struct Conn *C)
45 {
46 latency += Conn_lifetime(C);
47 }
48
43 49 int main(void) int main(void)
44 50 { {
45 51 int ret; int ret;
 
... ... int main(void)
48 54 unsigned int i; unsigned int i;
49 55 struct Conn *C; struct Conn *C;
50 56
51 buf_size = 4096;
52 57 buf = malloc(buf_size); buf = malloc(buf_size);
53 58 if (!buf) { if (!buf) {
54 59 printf("Cannnot alloc %u bytes!\n", buf_size); printf("Cannnot alloc %u bytes!\n", buf_size);
 
... ... int main(void)
62 67 printf("Port=%d\n", port); printf("Port=%d\n", port);
63 68 printf("Debug=%d\n", debug); printf("Debug=%d\n", debug);
64 69 printf("buf_size=%d\n", buf_size); printf("buf_size=%d\n", buf_size);
70 printf("sys: %s\n", Conn_sys());
65 71
66 72 Conn_default_ibuf = 4096; Conn_default_ibuf = 4096;
67 73 Conn_default_obuf = 4096; Conn_default_obuf = 4096;
 
... ... int main(void)
74 80
75 81 Conn_connected_cb = c_connected; Conn_connected_cb = c_connected;
76 82 Conn_error_cb = c_error; Conn_error_cb = c_error;
83 Conn_close_cb = c_close;
77 84
78 85 gettimeofday(&start, NULL); gettimeofday(&start, NULL);
79 86
 
... ... int main(void)
129 136 break; break;
130 137 } else if (ret == 0) } else if (ret == 0)
131 138 break; break;
139 printf("%d event(s), %llu error(s).\n",
140 ret, errors);
132 141 } }
133 142
143 free(buf);
144
134 145 gettimeofday(&end, NULL); gettimeofday(&end, NULL);
135 146
136 147 printf("\n"); printf("\n");
137 148
138 149 elap = 1000000 * (end.tv_sec - start.tv_sec) + end.tv_usec - start.tv_usec; elap = 1000000 * (end.tv_sec - start.tv_sec) + end.tv_usec - start.tv_usec;
139 150 printf("Finish in %d.%06d. ipv4conns=%d. ipv6conns=%d. Total=%d. ends=%d" printf("Finish in %d.%06d. ipv4conns=%d. ipv6conns=%d. Total=%d. ends=%d"
140 " Conns per sec = %d, errors = %llu, bytes=%llu\n",
151 " Conns per sec = %d, errors = %llu, bytes=%llu"
152 " latency=%llums"
153 "\n",
141 154 elap / 1000000, elap % 1000000, elap / 1000000, elap % 1000000,
142 155 ipv4conns, ipv6conns, ipv4conns + ipv6conns, ipv4conns, ipv6conns, ipv4conns + ipv6conns,
143 156 ends, (ipv4conns + ipv6conns) / (elap / 1000000 + 1), ends, (ipv4conns + ipv6conns) / (elap / 1000000 + 1),
144 errors, bytes);
157 errors, bytes, latency);
145 158
146 159 Conn_shutdown(); Conn_shutdown();
147 160
File examples/blackhole_s.c changed (mode: 100644) (index b253229..33441dd)
8 8 #include <Conn.h> #include <Conn.h>
9 9
10 10 /* Global variables */ /* Global variables */
11 static unsigned short debug = 20;
12
13 static int port = 9000;
11 static unsigned short debug = 4;
14 12 static short ipv4 = 1, ipv6 = 1; static short ipv4 = 1, ipv6 = 1;
13 static int port = 9000;
14
15 15 static unsigned long long bytes = 0; static unsigned long long bytes = 0;
16 16 static unsigned long long errors = 0; static unsigned long long errors = 0;
17 17
18
18 19 static void s_accept_error(struct Conn *C) static void s_accept_error(struct Conn *C)
19 20 { {
20 21 printf("Cannot accept a new connection via %llu!\n", printf("Cannot accept a new connection via %llu!\n",
 
... ... int main(void)
48 49 printf("\tPort=%d\n", port); printf("\tPort=%d\n", port);
49 50 printf("\tDebug=%d\n", debug); printf("\tDebug=%d\n", debug);
50 51 printf("\tipv4=%s ipv6=%s\n", (ipv4 == 1) ? "on" : "off", (ipv6 == 1) ? "on" : "off"); printf("\tipv4=%s ipv6=%s\n", (ipv4 == 1) ? "on" : "off", (ipv6 == 1) ? "on" : "off");
52 printf("\tsys: %s\n", Conn_sys());
51 53
52 54 Conn_default_ibuf = 4096; Conn_default_ibuf = 4096;
53 55 Conn_default_obuf = 4096; Conn_default_obuf = 4096;
 
... ... int main(void)
60 62 return 1; return 1;
61 63 } }
62 64
65 Conn_data_cb = s_data;
66 Conn_error_cb = s_error;
67 Conn_accept_error_cb = s_accept_error;
68
63 69 if (ipv4 == 1) { if (ipv4 == 1) {
64 70 printf("Trying to register IPv4 socket...\n"); printf("Trying to register IPv4 socket...\n");
65 71 C = Conn_alloc(); C = Conn_alloc();
 
... ... int main(void)
100 106 } }
101 107 } }
102 108
103 Conn_data_cb = s_data;
104 Conn_error_cb = s_error;
105 Conn_accept_error_cb = s_accept_error;
106
107 109 while (1) { while (1) {
108 110 /* -1 we do not have any other business but wait for an event */ /* -1 we do not have any other business but wait for an event */
109 111 ret = Conn_poll(-1); ret = Conn_poll(-1);
 
... ... int main(void)
117 119
118 120 Conn_shutdown(); Conn_shutdown();
119 121
120 printf("Finish. Errors=%llu, Bytes=%llu!\n\n", errors, bytes);
122 printf("Finish. Errors=%llu, bytes=%llu.\n\n",
123 errors, bytes);
121 124
122 125 return 0; return 0;
123 126 } }
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/catalinux/Conn

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/catalinux/Conn

Clone this repository using git:
git clone git://git.rocketgit.com/user/catalinux/Conn

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main