a simple object-oriented socket wrapper object model inspired by Zed Shaw More...
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <sys/un.h>
#include "debug.h"
#include "socket.h"
#include "util.h"
#include "list.h"
Functions | |
co_obj_t * | co_fd_create (co_obj_t *parent, int fd) |
creates a file descriptor object More... | |
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 | |
co_socket_t | unix_socket_proto |
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().
Variable Documentation
co_socket_t unix_socket_proto |
Generated on Fri Jun 6 2014 13:22:05 for commotiond by 1.8.7