KronkNet 1.0
Loading...
Searching...
No Matches
connection.h
1/*
2** FREE PROJECT, 2026
3** KRONKNET
4** File description:
5** Connection struct definition
6*/
7#ifndef KRONKNET_CONNECTION_IMPL_H
8 #define KRONKNET_CONNECTION_IMPL_H
9 #include "kronknet/callback/callback.h"
10 #include "kronknet/macros/types.h"
11 #include "kronknet/utils/rbuff/rbuff.h"
12 #include <stdbool.h>
13 #include <stddef.h>
14 #include "../platform/poller.h"
15 #include <stdint.h>
16
17typedef int (*knConnection_sendHook)(knConnection *, const void *, size_t);
18
20
27typedef struct kronknet_connection_s {
28
29 knBool disconnected;
30 knSocket fd;
31 knFlags flags;
32 size_t id;
33 knAddr addr;
34 knPort port;
35 char ip[INET6_ADDRSTRLEN];
36 uint64_t last_data;
37 void *user_ptr;
38 knRBuff *out_buff;
39 knConnection_sendHook sendHook;
40 knPoller *poller;
41 knConnection *udp_next;
42
43} knConnection;
44
45
46// TODO: Documentation
47knConnection *knConnection_accept(const knServer *server);
48void knConnection_destroy(knConnection *conn);
49
50knConnection *knConnection_create(const knAddr* addr, knFlags flags);
51
52int knConnection_setEvents(knConnection *conn, uint32_t events);
53
54#endif /* KRONKNET_CONNECTION_IMPL_H */
Definition connection.h:27
knAddr addr
The actual addr.
Definition connection.h:33
knSocket fd
The fd of the client (or the server in UDP mode).
Definition connection.h:30
knConnection * udp_next
UDP: the next connection whose address has the same key (see knServer_udpFind).
Definition connection.h:41
knPoller * poller
The poller of the server pool.
Definition connection.h:40
knFlags flags
The flags.
Definition connection.h:31
knConnection_sendHook sendHook
The send hook.
Definition connection.h:39
knRBuff * out_buff
The out buffer.
Definition connection.h:38
char ip[INET6_ADDRSTRLEN]
The well-formated ip adrr.
Definition connection.h:35
void * user_ptr
The user datas (eg User struct ...).
Definition connection.h:37
knBool disconnected
Is disconnected ?
Definition connection.h:29
knPort port
The port using by the connection.
Definition connection.h:34
uint64_t last_data
The last time (ms).
Definition connection.h:36
size_t id
The id of the connection ( !same as fd ).
Definition connection.h:32