0.0.002
ddat interop with dat js cable interop with cabal js ddat's frontend = dat-thang cable fe = cable-thang dillo support based on cel's dillo-dat bootstrap node xplatform support Signed-off-by: divo <418@cryspace.space>
This commit is contained in:
1 parent
f0f91540be
commit
b735900f2e
323 files changed
+134347
-343
No files matched your search
@@ -0,0 +1,36 @@
|
||||
#ifndef DAT_NET_H
|
||||
#define DAT_NET_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "dat_socket.h"
|
||||
|
||||
#define DATNET_PORT 3282
|
||||
#define DATNET_MAX_PACKET 1400
|
||||
#define DATNET_TOPIC_BYTES 32
|
||||
#define DATNET_PEERID_BYTES 32
|
||||
|
||||
typedef struct {
|
||||
dat_socket_t fd;
|
||||
struct sockaddr_storage addr;
|
||||
socklen_t addrlen;
|
||||
uint8_t id[DATNET_PEERID_BYTES];
|
||||
} dat_peer_t;
|
||||
|
||||
typedef struct datnet {
|
||||
dat_socket_t sock;
|
||||
uint8_t topic[DATNET_TOPIC_BYTES];
|
||||
uint8_t peerid[DATNET_PEERID_BYTES];
|
||||
void *context;
|
||||
void (*on_message)(struct datnet *net, dat_peer_t *peer, const uint8_t *msg, size_t len);
|
||||
} datnet_t;
|
||||
|
||||
int datnet_init(datnet_t *net, const uint8_t topic[DATNET_TOPIC_BYTES],
|
||||
const uint8_t peerid[DATNET_PEERID_BYTES]);
|
||||
int datnet_bind(datnet_t *net, const char *host, uint16_t port);
|
||||
int datnet_poll(datnet_t *net, int timeout_ms);
|
||||
int datnet_send(datnet_t *net, const dat_peer_t *peer,
|
||||
const uint8_t *message, size_t length);
|
||||
int datnet_close(datnet_t *net);
|
||||
|
||||
#endif /* DAT_NET_H */
|
||||
Reference in new issue
Block a user