a simple object-oriented socket wrapper object model inspired by Zed Shaw More...
Go to the source code of this file.
Classes | |
struct | co_fd_t |
struct | co_socket_t |
struct | unix_socket_t |
Macros | |
#define | MAX_IPPROTO 255 |
#define | MAX_CONNECTIONS 32 |
Typedefs | |
typedef struct co_fd_t | co_fd_t |
typedef struct co_socket_t | co_socket_t |
typedef struct unix_socket_t | unix_socket_t |
Functions | |
co_obj_t * | co_fd_create (co_obj_t *parent, int fd) |
creates a file descriptor object More... | |
struct co_socket_t | __attribute__ ((packed)) |
co_obj_t * | co_socket_create (size_t size, co_socket_t proto) |
creates a socket from specified values or initializes defaults More... | |
int | co_socket_init (co_obj_t *self) |
creates a socket from specified values or initializes defaults More... | |
int | co_socket_destroy (co_obj_t *self) |
closes a socket and removes it from memory More... | |
int | co_socket_hangup (co_obj_t *self, co_obj_t *context) |
closes a socket and changes its state information More... | |
int | co_socket_send (co_obj_t *self, char *outgoing, size_t length) |
sends a message on a specified socket More... | |
int | co_socket_receive (co_obj_t *self, co_obj_t *fd, char *incoming, size_t length) |
receives a message on the listening socket More... | |
int | co_socket_setopt (co_obj_t *self, int level, int option, void *optval, socklen_t optvallen) |
sets custom socket options, if specified by user More... | |
int | co_socket_getopt (co_obj_t *self, int level, int option, void *optval, socklen_t optvallen) |
gets custom socket options specified from the user More... | |
int | unix_socket_init (co_obj_t *self) |
initializes a unix socket More... | |
int | unix_socket_bind (co_obj_t *self, const char *endpoint) |
binds a unix socket to a specified endpoint More... | |
int | unix_socket_connect (co_obj_t *self, const char *endpoint) |
connects a socket to specified endpoint More... | |
Variables | |
struct co_fd_t | __attribute__ |
co_obj_t | _header |
uint8_t | _exttype |
uint8_t | _len |
char * | uri |
co_fd_t * | fd |
co_obj_t * | rfd_lst |
bool | fd_registered |
struct sockaddr * | local |
struct sockaddr * | remote |
bool | listen |
int(* | init )(co_obj_t *self) |
int(* | destroy )(co_obj_t *self) |
int(* | hangup )(co_obj_t *self, co_obj_t *context) |
int(* | bind )(co_obj_t *self, const char *endpoint) |
int(* | connect )(co_obj_t *self, const char *endpoint) |
int(* | send )(co_obj_t *self, char *outgoing, size_t length) |
int(* | receive )(co_obj_t *self, co_obj_t *fd, char *incoming, size_t length) |
int(* | setopt )(co_obj_t *self, int level, int option, void *optval, socklen_t optvallen) |
int(* | getopt )(co_obj_t *self, int level, int option, void *optval, socklen_t optvallen) |
int(* | poll_cb )(co_obj_t *self, co_obj_t *context) |
int(* | register_cb )(co_obj_t *self, co_obj_t *context) |
unsigned int | events |
co_socket_t | proto |
char * | path |
Detailed Description
a simple object-oriented socket wrapper object model inspired by Zed Shaw
Function Documentation
creates a file descriptor object
- Parameters
-
fd file descriptor int
Referenced by _watch(), co_socket_init(), co_socket_receive(), and unix_socket_init().
co_obj_t* co_socket_create | ( | size_t | size, |
co_socket_t | proto | ||
) |
creates a socket from specified values or initializes defaults
- Parameters
-
size size of socket struct proto socket protocol
References co_socket_destroy(), co_socket_getopt(), co_socket_hangup(), co_socket_receive(), co_socket_send(), and co_socket_setopt().
int co_socket_destroy | ( | co_obj_t * | self | ) |
closes a socket and removes it from memory
- Parameters
-
self socket name
References co_list_parse().
Referenced by co_socket_create().
int co_socket_getopt | ( | co_obj_t * | self, |
int | level, | ||
int | option, | ||
void * | optval, | ||
socklen_t | optvallen | ||
) |
gets custom socket options specified from the user
- Parameters
-
self socket name level the networking level to be customized option the option to be changed optval the value for the new option optvallen the length of the value for the new option
Referenced by co_socket_create().
closes a socket and changes its state information
- Parameters
-
self socket name context co_obj_t context pointer (currently unused)
References co_list_contains(), and co_list_delete().
Referenced by co_socket_create().
int co_socket_init | ( | co_obj_t * | self | ) |
creates a socket from specified values or initializes defaults
- Parameters
-
size size of socket struct proto socket protocol
References co_fd_create().
receives a message on the listening socket
- Parameters
-
self socket name incoming message received length length of message
References co_fd_create(), and co_list_append().
Referenced by co_socket_create().
int co_socket_send | ( | co_obj_t * | self, |
char * | outgoing, | ||
size_t | length | ||
) |
sends a message on a specified socket
- Parameters
-
self socket name outgoing message to be sent length length of message
Referenced by co_socket_create().
int co_socket_setopt | ( | co_obj_t * | self, |
int | level, | ||
int | option, | ||
void * | optval, | ||
socklen_t | optvallen | ||
) |
sets custom socket options, if specified by user
- Parameters
-
self socket name level the networking level to be customized option the option to be changed optval the value for the new option optvallen the length of the value for the new option
Referenced by co_socket_create().
int unix_socket_bind | ( | co_obj_t * | self, |
const char * | endpoint | ||
) |
binds a unix socket to a specified endpoint
- Parameters
-
self socket name endpoint specified endpoint for socket (file path)
int unix_socket_connect | ( | co_obj_t * | self, |
const char * | endpoint | ||
) |
connects a socket to specified endpoint
- Parameters
-
self socket name endpoint specified endpoint for socket (file path)
int unix_socket_init | ( | co_obj_t * | self | ) |
initializes a unix socket
- Parameters
-
self socket name
References co_fd_create().
Generated on Fri Jun 6 2014 13:22:05 for commotiond by 1.8.7