Implemented server
This commit is contained in:
36
server.h
Normal file
36
server.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#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
|
||||
Reference in New Issue
Block a user