football
socket abstraction layer
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Enumerations | Functions
fb_socketmgr.c File Reference

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"

Data Structures

struct  socket_data_t
 

Macros

#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
 

Typedefs

typedef struct socket_data_t FB_SOCKET_DATA
 
typedef enum select_action_t ACTION
 

Enumerations

enum  select_action_t {
  ACTION_READING , ACTION_WRITING , ACTION_FAULTING , ACTION_BUFFERING ,
  ACTION_COUNT , ACTION_SELECT_COUNT = 3
}
 

Functions

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_EVENTfb_process_event (int socket_fd, ACTION action)
 
FB_EVENTfb_poll (void)
 Quick poll with no waiting.
 
FB_EVENTfb_poll_with_timeout (double timeout)
 Poll with a duration.
 
FB_EVENTfb_wait (void)
 Poll indefinitely.
 
FB_EVENTfb_poll_until (time_t untilwhen)
 Poll with a timeout at a specific time.
 

Detailed Description

Football socket management and dispatching.

Function Documentation

◆ fb_accept_input()

void fb_accept_input ( FB_CONNECTION connection,
bool  input 
)

Public interface to enable/disable reading on a connection.

Parameters
connection- the connection to adjust.
inputtrue to enable reading, false to disable.

◆ fb_poll()

FB_EVENT * fb_poll ( void  )

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
untilwhenTime 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
timeoutin seconds.
Returns
An event.

◆ fb_register()

bool fb_register ( int  socket_fd,
FB_SOCKETTYPE  type,
void *  thing 
)

Add a socket to the registry.

Parameters
socket_fdThe file descriptor of the socket being added.
typeType of socket (service, connection, user...)
thingPointer 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_fdthe file descriptor to unregister

◆ fb_wait()

FB_EVENT * fb_wait ( void  )

Poll indefinitely.

Returns
An event.