Functions | Variables

sst/elements/genericProc/programs/libcprops/socket.c File Reference

socket framework implementation More...

#include "common.h"
#include "log.h"
#include "util.h"
#include "hashtable.h"
#include "vector.h"
#include "thread.h"
#include "socket.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <signal.h>
#include <fcntl.h>
#include <errno.h>

Functions

void cp_socket_init ()
 recommended to call before using socket functions
void cp_socket_stop (cp_socket *sock)
CPROPS_DLL void cp_tcp_add_shutdown_callback (void(*cb)(void *), void *prm)
 add callback to be made on tcp layer shutdown
void cp_socket_stop_all ()
 call from signal handler to stop sockets in waiting select() and close all connections
void cp_socket_shutdown ()
 performs cleanup
int setnonblocking (int sock)
cp_connection_descriptorcp_connection_descriptor_create (cp_socket *sock, struct sockaddr_in *addr, int fd)
 internal: create a new connection descriptor
void cp_connection_descriptor_destroy (cp_connection_descriptor *conn_desc)
 deallocate a connection descriptor
cp_socketcp_socket_create (int port, cp_socket_strategy strategy, void *fn)
 create a new cp_socket struct
void cp_socket_set_backlog (cp_socket *socket, int backlog)
 set number of outstanding requests before accept() fails new connections
void cp_socket_set_delay (cp_socket *socket, struct timeval delay)
 delay time before re-accept()ing
void cp_socket_set_delay_sec (cp_socket *socket, long sec)
 seconds before re-accept()ing
void cp_socket_set_delay_usec (cp_socket *socket, long usec)
 microseconds before re-accept()ing
void cp_socket_set_poolsize_min (cp_socket *socket, int min)
 lower size limit for threadpool implementation
void cp_socket_set_poolsize_max (cp_socket *socket, int max)
 upper size limit for threadpool implementation
void cp_socket_set_owner (cp_socket *socket, void *owner)
 useful free pointer for client code
void * cp_socket_add_shutdown_callback (cp_socket *sock, void(*cb)(void *), void *prm)
 add a callback to be made on socket shutdown
void cp_socket_delete (cp_socket *sock)
 deallocate a socket descriptor
int cp_socket_listen (cp_socket *sock)
 cp_socket_listen attempts to create a SOCK_STREAM socket with socket(), bind to a local port with bind(), and set the socket to listen for connections with listen().
int cp_socket_select_callback_impl (cp_socket *sock)
int cp_socket_select_threadpool_impl (cp_socket *sock)
int cp_socket_select (cp_socket *sock)
 block and wait for connections
int cp_socket_connection_close (cp_socket *sock, int fd)
 close a (non ssl) connection
int cp_connection_descrpitor_read (cp_connection_descriptor *desc, char *buf, int len)
 read from a connection descriptor
int cp_connection_descriptor_write (cp_connection_descriptor *desc, char *buf, int len)
 write on a connection descriptor

Variables

static volatile int socket_reg_id = 0
static cp_hashlistsocket_registry
static cp_vector * shutdown_hook = NULL
static volatile int initialized = 0
static volatile int shutting = 0
volatile int stopping_all = 0

Detailed Description

socket framework implementation