This commit is contained in:
Nishi 2026-01-08 00:35:00 +09:00
commit 15c5376364
Signed by: nishi
GPG key ID: 27EF69B208EB9343
12 changed files with 1358 additions and 1312 deletions

View file

@ -1,11 +1,11 @@
#include <gbnet.h>
gbnet_client_t* gbnet_client(const char* host, int port) {
gbnet_client_t* client = malloc(sizeof(*client));
struct addrinfo hints;
char p[32];
struct addrinfo* result;
struct addrinfo* rp;
gbnet_client_t* client = malloc(sizeof(*client));
struct addrinfo hints;
char p[32];
struct addrinfo* result;
struct addrinfo* rp;
if(port == 0) port = NET_PORT;
sprintf(p, "%d", port);
@ -55,9 +55,9 @@ void gbnet_client_on_disconnect(gbnet_client_t* client, void (*on_disconnect)(gb
}
int gbnet_client_poll(gbnet_client_t* client) {
struct pollfd pfd;
struct pollfd pfd;
gbnet_packet_t pkt;
int ret;
int ret;
pfd.fd = client->fd;
pfd.events = POLLIN | POLLPRI;

View file

@ -4,7 +4,7 @@
gbnet_server_t* gbnet_server(int port) {
gbnet_server_t* server = malloc(sizeof(*server));
int val;
int val;
if(port == 0) port = NET_PORT;
@ -68,7 +68,7 @@ void gbnet_server_loop(gbnet_server_t* server) {
if(server->on_tick != NULL) server->on_tick(server);
if(pfd[0].revents & POLLIN) {
gbnet_client_t client;
gbnet_client_t client;
struct sockaddr_in address;
int len = sizeof(address);

View file

@ -5,10 +5,10 @@
#define CHUNK 512
int gbnet_packet_send(int fd, gbnet_packet_t* packet) {
int r;
int r;
gbnet_packet_header_t h;
int len = 0;
unsigned char* data = NULL;
int len = 0;
unsigned char* data = NULL;
if(packet->header.length > 0) {
z_stream strm;

File diff suppressed because it is too large Load diff