40 lines
908 B
C
40 lines
908 B
C
#ifndef __CLIENT_H
|
|
#define __CLIENT_H
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
|
|
// Setup client module.
|
|
// Returns:
|
|
// - true on success
|
|
// - false on failure
|
|
bool client_init();
|
|
|
|
// Cleanup all pending connections.
|
|
void client_deinit();
|
|
|
|
// Connect to the server.
|
|
// Parameters:
|
|
// - host - server host
|
|
// - port - server port
|
|
// Returns:
|
|
// - true on success
|
|
// Remarks:
|
|
// - the socket is managed by this module. It will be
|
|
// added to connection module after connection succeeds.
|
|
bool client_connect(const char *host, uint16_t port);
|
|
|
|
// Handle event on the socket managed by this module.
|
|
// Parameters:
|
|
// - fd - socket
|
|
// - events - events as returned by epoll
|
|
// Returns:
|
|
// - true if the socket is managed by this module
|
|
// - false if the socket is not managed by this module
|
|
// Remarks:
|
|
// - no checks are done
|
|
bool client_event(int fd, uint32_t events);
|
|
|
|
|
|
#endif
|