Football socket management and dispatching.
More...
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <time.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/select.h>
#include <assert.h>
#include "fb_service.h"
|
|
#define | _BSD_SOURCE /* strdup() */ |
| |
|
#define | _DARWIN_C_SOURCE /* strdup() on OS X */ |
| |
|
#define | _DEFAULT_SOURCE |
| |
|
#define | FD_COPY(from, to) memmove(to, from, sizeof(*(from))) |
| |
|
#define | fb_lock_socketmanager_mutex() true |
| |
|
|
typedef struct socket_data_t | FB_SOCKET_DATA |
| |
|
typedef enum select_action_t | ACTION |
| |
|
| enum | select_action_t {
ACTION_READING
, ACTION_WRITING
, ACTION_FAULTING
, ACTION_BUFFERING
,
ACTION_COUNT
, ACTION_SELECT_COUNT = 3
} |
| |
|
|
void | fb_schedule_reap (FB_SERVICE *service) |
| |
|
void | fb_queue_event (FB_EVENT *event) |
| |
|
void | fb_dispose_event (FB_EVENT *event) |
| |
|
void | fb_interrupt (void) |
| | Return an FB_EVENT_INTERRUPTED on current or next poll.
|
| |
| bool | fb_register (int socket_fd, FB_SOCKETTYPE type, void *thing) |
| | Add a socket to the registry.
|
| |
| void | fb_unregister (int socket_fd) |
| | Remove a socket from the registry.
|
| |
|
void | fb_set_socket_select_flags (int socket_fd, ACTION group, bool enable) |
| |
|
void | fb_set_buffering (int socket_fd, bool enable) |
| |
|
void | fb_set_writable (int socket_fd, bool enable) |
| |
|
void | fb_set_readable (int socket_fd, bool enable) |
| |
| void | fb_accept_input (FB_CONNECTION *connection, bool input) |
| | Public interface to enable/disable reading on a connection.
|
| |
|
FB_EVENT * | fb_process_event (int socket_fd, ACTION action) |
| |
| FB_EVENT * | fb_poll (void) |
| | Quick poll with no waiting.
|
| |
| FB_EVENT * | fb_poll_with_timeout (double timeout) |
| | Poll with a duration.
|
| |
| FB_EVENT * | fb_wait (void) |
| | Poll indefinitely.
|
| |
| FB_EVENT * | fb_poll_until (time_t untilwhen) |
| | Poll with a timeout at a specific time.
|
| |
Football socket management and dispatching.
- Football socket abstraction layer
- Author
- Perette Barella
- Date
- 2012-03-03
- Copyright
- Copyright 2012-2021 Devious Fish. All rights reserved.
◆ fb_accept_input()
Public interface to enable/disable reading on a connection.
- Parameters
-
| connection | - the connection to adjust. |
| input | true to enable reading, false to disable. |
◆ fb_poll()
Quick poll with no waiting.
- Returns
- An event.
◆ fb_poll_until()
| FB_EVENT * fb_poll_until |
( |
time_t |
untilwhen | ) |
|
Poll with a timeout at a specific time.
- Parameters
-
| untilwhen | Time at which timeout should occur. |
- Returns
- An event.
◆ fb_poll_with_timeout()
| FB_EVENT * fb_poll_with_timeout |
( |
double |
timeout | ) |
|
Poll with a duration.
- Parameters
-
- Returns
- An event.
◆ fb_register()
| bool fb_register |
( |
int |
socket_fd, |
|
|
FB_SOCKETTYPE |
type, |
|
|
void * |
thing |
|
) |
| |
Add a socket to the registry.
- Parameters
-
| socket_fd | The file descriptor of the socket being added. |
| type | Type of socket (service, connection, user...) |
| thing | Pointer of type indicated by 'type'. |
- Returns
- true on success, false on failure
◆ fb_unregister()
| void fb_unregister |
( |
int |
socket_fd | ) |
|
Remove a socket from the registry.
Always succeeds, unless there's a bug.
- Parameters
-
| socket_fd | the file descriptor to unregister |
◆ fb_wait()
Poll indefinitely.
- Returns
- An event.