feat: add C & Zig bindings for socket
This commit is contained in:
parent
e19ff271d0
commit
d1cb42d53c
11 changed files with 209 additions and 13 deletions
25
include/thespian/c/socket.h
Normal file
25
include/thespian/c/socket.h
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#pragma once
|
||||
|
||||
// NOLINTBEGIN(modernize-use-trailing-return-type)
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
struct thespian_socket_handle;
|
||||
struct thespian_socket_handle *thespian_socket_create(const char *tag, int fd);
|
||||
int thespian_socket_write(struct thespian_socket_handle *, const char *data,
|
||||
size_t len);
|
||||
int thespian_socket_write_binary(struct thespian_socket_handle *,
|
||||
const uint8_t *data, size_t len);
|
||||
int thespian_socket_read(struct thespian_socket_handle *);
|
||||
int thespian_socket_close(struct thespian_socket_handle *);
|
||||
void thespian_socket_destroy(struct thespian_socket_handle *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
// NOLINTEND(modernize-use-trailing-return-type)
|
||||
|
|
@ -26,4 +26,12 @@ struct socket {
|
|||
socket_ref ref;
|
||||
};
|
||||
|
||||
// C++ helpers used by the C binding layer
|
||||
|
||||
void socket_write(socket_impl *h, std::string_view data);
|
||||
void socket_write_binary(socket_impl *h, const std::vector<uint8_t> &data);
|
||||
void socket_read(socket_impl *h);
|
||||
void socket_close(socket_impl *h);
|
||||
void destroy_socket(socket_impl *h);
|
||||
|
||||
} // namespace thespian
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue