Files
ipoim/server.h
Nikita Tyukalov, ASUS, Linux 1cc2ef41d1 Implemented server
2026-03-24 19:45:17 +03:00

37 lines
884 B
C

#ifndef __SERVER_H
#define __SERVER_H
#include <stdbool.h>
#include <stdint.h>
// Open the server.
// Parameters:
// - host - hostname or IP address (domain names are OK)
// - port - port to use
// Returns:
// - -1 on failure
// - file descriptor of the server on success
// Remarks:
// - call only after server_init
// - you must add returned fd to epoll with EPOLLIN events
int server_open(const char* host, int port);
// Close the server.
// Remarks:
// - the socket is automatically removed from epoll
void server_close();
// Notify the server that an event happened on its socket.
// Returns:
// - true on success
// - false on failure
// Remarks:
// - the server accepts the connection and starts managing
// it with connection.h
// - you should stop close the server if this function
// returns false
bool server_event(uint32_t events);
#endif