idk
This commit is contained in:
parent
2c4198fbc6
commit
15c5376364
12 changed files with 1358 additions and 1312 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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
Loading…
Add table
Add a link
Reference in a new issue