You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+9-12Lines changed: 9 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,20 +9,16 @@ See [INSTALL](INSTALL.md)
9
9
The collector allows to read and parse UDP-notif protocol messages from a ip/port specified on the parameters. It allows to get directly the buffer and the metadata of the message in a struct.
10
10
11
11
The api is in `unyte_udp_collector.h`:
12
-
-`unyte_udp_collector_t *unyte_udp_start_collector(unyte_udp_options_t *options)` from `unyte_udp_collector.h`: Initialize the UDP-notif messages collector. It accepts a struct with different options: address (the IP address to listen to), port (port to listen to), recvmmsg_vlen (vlen used on recvmmsg syscall meaning how many messages to receive on every syscall, by default 10)
13
-
-`unyte_udp_collector_t *unyte_udp_start_collector_sk(unyte_udp_sk_options_t *options)` from `unyte_udp_collector.h`: Initialize the UDP-notif messages collector binded to a socket. It accepts a struct with different options: socket file descriptor to listen on, recvmmsg_vlen (vlen used on recvmmsg syscall meaning how many messages to receive on every syscall, by default 10)
12
+
-`int unyte_udp_create_socket(char *address, char *port, uint64_t buffer_size)` from `unyte_udp_utils.h`: Helper that creates and binds a socket to an address and port.
13
+
-`unyte_udp_collector_t *unyte_udp_start_collector(unyte_udp_options_t *options)` from `unyte_udp_collector.h`: Initialize the UDP-notif messages collector. It accepts a struct with different options: socketfd of the socket to listen to, recvmmsg_vlen (vlen used on recvmmsg syscall meaning how many messages to receive on every syscall, by default 10)...
14
14
-`void *unyte_udp_queue_read(unyte_udp_queue_t *queue)` from `unyte_udp_queue.h` : read from a queue a struct with all the message buffer and metadata.
15
15
-`int unyte_udp_free_all(unyte_seg_met_t *seg)` from `unyte_udp_collector.h`: free all struct used on a message received.
16
16
17
17
Simple example of usage :
18
18
```c
19
19
#include<stdio.h>
20
-
#include<stdlib.h>
21
-
#include<pthread.h>
22
-
#include<stdint.h>
23
-
#include<string.h>
24
-
#include<signal.h>
25
20
#include<unistd.h>
21
+
#include<arpa/inet.h>
26
22
27
23
// include installed library headers
28
24
#include<unyte-udp-notif/unyte_udp_collector.h>
@@ -34,10 +30,13 @@ Simple example of usage :
34
30
35
31
intmain()
36
32
{
33
+
// Initialize socket and bind it to the address
34
+
int socketfd = unyte_udp_create_socket(ADDR, PORT, DEFAULT_SK_BUFF_SIZE);
35
+
37
36
// Initialize collector options
38
37
unyte_udp_options_t options = {0};
39
-
options.address = ADDR;
40
-
options.port = PORT;
38
+
// add socket fd reference to options
39
+
options.socket_fd = socketfd
41
40
// if argument set to 0, defaults are used
42
41
options.recvmmsg_vlen = 0; // vlen parameter for recvmmsg. Default: 10
0 commit comments