29 lines
1 KiB
C
29 lines
1 KiB
C
#pragma once
|
|
|
|
#include <stdbool.h>
|
|
#include <sys/socket.h>
|
|
#include <unistd.h>
|
|
|
|
struct epoll_event;
|
|
struct buffer_context;
|
|
struct sockaddr_storage;
|
|
|
|
typedef struct buffer_context {
|
|
size_t len;
|
|
size_t pos;
|
|
const void* buf;
|
|
} bctx_t;
|
|
|
|
bool addr_listen_multiple(int epoll_fd, const char** pairs, int num, int* slist, size_t size);
|
|
bool parse_address_port_pair(const char* in, char* address, char* port);
|
|
bool is_valid_port(const char* port);
|
|
bool fd_set_non_blocking(int sock_fd);
|
|
bool epoll_schedule_write(int epoll_fd, struct epoll_event* event, int sock_t);
|
|
int socket_bind_tcp(const char* address, const char* port);
|
|
int socket_accept_connection(int listen_s, int epoll_fd, struct epoll_event* event);
|
|
int on_receive(int socket_s, char* buf, size_t size);
|
|
bool bs_send_data(struct buffer_context* bs, int sock_s);
|
|
bool peer_to_sockaddr(int peer_s, struct sockaddr_storage* addr, socklen_t* len);
|
|
bool peer_to_str(int peer_s, char* buf, size_t len);
|
|
bool sockaddr_to_str(
|
|
struct sockaddr_storage* ss, socklen_t slen, char* host, size_t hlen, char* port, size_t plen);
|