B2BITS FIX Antenna HFT  1.0.13
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Macros | Typedefs | Functions | Variables
sockets_iface.h File Reference
#include <stdio.h>
#include "b2b_platform.h"
#include "sockets_session.h"
#include "sockets_logging.h"
+ Include dependency graph for sockets_iface.h:

Classes

struct  Server
 
struct  Socket
 
struct  SocketEvents
 
struct  SocketMethods
 
struct  Sockets
 
struct  SocketThread
 

Macros

#define CONNECT_TIMEOUT_MS   (10 * 1000)
 
#define MAX_LISTENING_SOCKETS   128
 
#define MAX_RUNTIME_SOCKETS_ON_SERVER   32
 
#define MS_BETWEEN_LOGCLIENT_TIMESLICES   500
 
#define MS_BETWEEN_RECONNECTS   3000
 
#define NANOSEC_IN_MS   1000000LL
 
#define SOCKET_RECV_BUF_SIZE   65536
 
#define SOCKET_THREAD_TIME_ACCESS_THROTTLE   10
 

Typedefs

typedef struct Socket Socket
 
typedef void(* SOCKET_ctor )(struct Socket *sock, struct Server *srv, int fd, int isListening, enum SocketID socketID, void *data)
 
typedef void(* SOCKET_dtor )(struct Socket *sock)
 
typedef int(* SOCKET_event_before_new_data_received )(struct Socket *sock)
 
typedef void(* SOCKET_event_can_write_nonblock )(struct Socket *sock)
 
typedef void(* SOCKET_event_disconnected )(struct Socket *sock)
 
typedef void(* SOCKET_event_incoming_connection_accepted )(struct Socket *sock)
 
typedef void(* SOCKET_event_new_data_received )(struct Socket *sock, char *buf, int len)
 
typedef void(* SOCKET_event_new_data_received_appended )(struct Socket *sock, char *buf, int startPos, int len)
 
typedef void(* SOCKET_event_outgoing_connected )(struct Socket *sock)
 
typedef void(* SOCKET_event_socket_closed )(struct Socket *sock)
 
typedef void(* SOCKET_event_socket_created )(struct Socket *sock)
 
typedef int(* SOCKET_getAddrAny )(int port, struct sockaddr_in *sin)
 
typedef int(* SOCKET_getAddrByName )(const char *hostAddr, int port, struct sockaddr_in *sin)
 
typedef int(* SOCKET_initSocketOptions )(struct Server *srv, int fd)
 
typedef int(* SOCKET_isConnected )(int fd)
 
typedef int(* SOCKET_recv_zero_copy )(struct Socket *sock, char **buf)
 
typedef int(* SOCKET_setNonblocking )(int fd)
 
typedef int(* SOCKET_setRecvBufferSize )(int fd, int size)
 
typedef int(* SOCKET_setSendBufferSize )(int fd, int size)
 
typedef int(* SOCKET_socket )(struct Server *srv, enum SocketID localSocketID)
 
typedef void(* SOCKET_socket_write_lock )(struct Socket *sock, int doLock)
 

Functions

void _initLoggerClient (struct SocketThread *thread)
 
void _initLoggerClient2 (struct SocketThread *thread, enum ServerID serverID, enum SocketID logSocketID)
 
struct Socketadd_socket (struct Server *srv, struct SocketMethods *type, int fd, int isListening, enum SocketID socketID, int connecting, void *socket_data)
 
void add_socket_thread (struct SocketThread *thread)
 
void addListeningSocket (struct Server *srv, enum SocketID socketID)
 
struct ServeraddServerToThread (struct SocketThread *thread, struct NetworkDeclaration *netDecl, enum ServerID serverID, struct SocketEvents *eventMethods)
 
static int event_before_new_data_received (struct Socket *sock)
 
static void event_can_write_nonblock (struct Socket *sock)
 
static void event_disconnected (struct Socket *sock)
 
static void event_incoming_connection_accepted (struct Socket *sock)
 
static void event_outgoing_connected (struct Socket *sock)
 
static void event_socket_closed (struct Socket *sock)
 
int get_socket (struct Server *srv, enum SocketID socketID, struct Socket **sock)
 
int getListenSocket (enum SocketID socketID, struct Server *hostingServer, struct Socket **returnSocket)
 
int getServerDecl (enum ServerID serverID, struct NetworkDeclaration *net, struct ServerDeclaration **decl)
 
struct ServergetServerFromThread (struct SocketThread *thread, enum ServerID id)
 
int getSocket (enum SocketID socketID, struct Server *hostingServer, struct Socket **returnSocket)
 
int getSocketDecl (enum SocketID socketID, struct NetworkDeclaration *net, struct SocketDeclaration **decl)
 
struct NetworkDeclarationnetwork_clone (struct NetworkDeclaration *netDecl, int size)
 
void remove_socket (struct Sockets *socks, int sock)
 
int socket_alloc_recvbuf (struct Socket *sock, int len)
 
static int socket_can_write (struct Socket *sock)
 
void socket_close (struct Socket *sock)
 
struct Socketsocket_connect (struct Server *srv, const char *address, int port, enum SocketID localSocketID, void *socket_data)
 
struct Socketsocket_connect_blocking (struct Server *srv, const char *address, int port, enum SocketID localSocketID, void *socket_data)
 
struct Socketsocket_connect_to_def_destination (struct Server *srv, enum SocketID localSocketID, void *socket_data)
 
struct Socketsocket_connect_to_def_destination_blocking (struct Server *srv, enum SocketID localSocketID, void *socket_data)
 
struct Socketsocket_connect_to_socket (struct Server *srv, enum SocketID localSocketID, struct NetworkDeclaration *remoteNet, enum SocketID remoteSocket, void *socket_data)
 
void socket_construct (struct Socket *newsock, struct Server *srv, struct SocketMethods *type, int fd, int isListening, enum SocketID socketID, void *socket_data)
 
void socket_ctor_def (struct Socket *sock, struct Server *srv, int fd, int isListening, enum SocketID socketID, void *data)
 
void socket_dtor_def (struct Socket *sock)
 
void socket_free_rcvbuf (struct Socket *sock)
 
static int socket_is_connected (struct Socket *sock)
 
int socket_realloc_recvbuf (struct Socket *sock, int len)
 
int socket_send (struct Socket *sock, const char *buf, int len)
 
int socket_send_blocking (struct Socket *sock, const char *buf, int len)
 
int socket_send_fast_cross_thread (struct Socket *sock, const char *buf, int len)
 
int socket_send_if_connected (struct Socket *sock, const char *buf, int len)
 
static void socket_set_recv_pos (struct Socket *sock, int pos)
 
void thread_construct (struct SocketThread *thread)
 
void thread_construct2 (struct SocketThread *thread, int createLogSocket)
 
void thread_decl_fork (struct NetworkDeclaration *netDecl, enum ThreadID threadID)
 
int thread_init_listen_daemon (struct SocketThread *thread)
 
int thread_job_timeslice (struct SocketThread *thread)
 
static void write_lock (struct Socket *sock)
 
static void write_unlock (struct Socket *sock)
 

Variables

struct SocketMethods FIFOSocketMethods
 
struct SocketMethods TCPSocketMethods
 

Macro Definition Documentation

#define CONNECT_TIMEOUT_MS   (10 * 1000)
#define MAX_LISTENING_SOCKETS   128
#define MAX_RUNTIME_SOCKETS_ON_SERVER   32
#define MS_BETWEEN_LOGCLIENT_TIMESLICES   500
#define MS_BETWEEN_RECONNECTS   3000
#define NANOSEC_IN_MS   1000000LL
#define SOCKET_RECV_BUF_SIZE   65536
#define SOCKET_THREAD_TIME_ACCESS_THROTTLE   10

Typedef Documentation

typedef struct Socket Socket
typedef void(* SOCKET_ctor)(struct Socket *sock, struct Server *srv, int fd, int isListening, enum SocketID socketID, void *data)
typedef void(* SOCKET_dtor)(struct Socket *sock)
typedef int(* SOCKET_event_before_new_data_received)(struct Socket *sock)
typedef void(* SOCKET_event_can_write_nonblock)(struct Socket *sock)
typedef void(* SOCKET_event_disconnected)(struct Socket *sock)
typedef void(* SOCKET_event_incoming_connection_accepted)(struct Socket *sock)
typedef void(* SOCKET_event_new_data_received)(struct Socket *sock, char *buf, int len)
typedef void(* SOCKET_event_new_data_received_appended)(struct Socket *sock, char *buf, int startPos, int len)
typedef void(* SOCKET_event_outgoing_connected)(struct Socket *sock)
typedef void(* SOCKET_event_socket_closed)(struct Socket *sock)
typedef void(* SOCKET_event_socket_created)(struct Socket *sock)
typedef int(* SOCKET_getAddrAny)(int port, struct sockaddr_in *sin)
typedef int(* SOCKET_getAddrByName)(const char *hostAddr, int port, struct sockaddr_in *sin)
typedef int(* SOCKET_initSocketOptions)(struct Server *srv, int fd)
typedef int(* SOCKET_isConnected)(int fd)
typedef int(* SOCKET_recv_zero_copy)(struct Socket *sock, char **buf)
typedef int(* SOCKET_setNonblocking)(int fd)
typedef int(* SOCKET_setRecvBufferSize)(int fd, int size)
typedef int(* SOCKET_setSendBufferSize)(int fd, int size)
typedef int(* SOCKET_socket)(struct Server *srv, enum SocketID localSocketID)
typedef void(* SOCKET_socket_write_lock)(struct Socket *sock, int doLock)

Function Documentation

void _initLoggerClient ( struct SocketThread thread)
void _initLoggerClient2 ( struct SocketThread thread,
enum ServerID  serverID,
enum SocketID  logSocketID 
)
struct Socket* add_socket ( struct Server srv,
struct SocketMethods type,
int  fd,
int  isListening,
enum SocketID  socketID,
int  connecting,
void *  socket_data 
)
void add_socket_thread ( struct SocketThread thread)
void addListeningSocket ( struct Server srv,
enum SocketID  socketID 
)
struct Server* addServerToThread ( struct SocketThread thread,
struct NetworkDeclaration netDecl,
enum ServerID  serverID,
struct SocketEvents eventMethods 
)
static int event_before_new_data_received ( struct Socket sock)
static
static void event_can_write_nonblock ( struct Socket sock)
static
static void event_disconnected ( struct Socket sock)
static
static void event_incoming_connection_accepted ( struct Socket sock)
static
static void event_outgoing_connected ( struct Socket sock)
static
static void event_socket_closed ( struct Socket sock)
static
int get_socket ( struct Server srv,
enum SocketID  socketID,
struct Socket **  sock 
)
int getListenSocket ( enum SocketID  socketID,
struct Server hostingServer,
struct Socket **  returnSocket 
)
int getServerDecl ( enum ServerID  serverID,
struct NetworkDeclaration net,
struct ServerDeclaration **  decl 
)
struct Server* getServerFromThread ( struct SocketThread thread,
enum ServerID  id 
)
int getSocket ( enum SocketID  socketID,
struct Server hostingServer,
struct Socket **  returnSocket 
)
int getSocketDecl ( enum SocketID  socketID,
struct NetworkDeclaration net,
struct SocketDeclaration **  decl 
)
struct NetworkDeclaration* network_clone ( struct NetworkDeclaration netDecl,
int  size 
)
void remove_socket ( struct Sockets socks,
int  sock 
)
int socket_alloc_recvbuf ( struct Socket sock,
int  len 
)
static int socket_can_write ( struct Socket sock)
inlinestatic
void socket_close ( struct Socket sock)
struct Socket* socket_connect ( struct Server srv,
const char *  address,
int  port,
enum SocketID  localSocketID,
void *  socket_data 
)
struct Socket* socket_connect_blocking ( struct Server srv,
const char *  address,
int  port,
enum SocketID  localSocketID,
void *  socket_data 
)
struct Socket* socket_connect_to_def_destination ( struct Server srv,
enum SocketID  localSocketID,
void *  socket_data 
)
struct Socket* socket_connect_to_def_destination_blocking ( struct Server srv,
enum SocketID  localSocketID,
void *  socket_data 
)
struct Socket* socket_connect_to_socket ( struct Server srv,
enum SocketID  localSocketID,
struct NetworkDeclaration remoteNet,
enum SocketID  remoteSocket,
void *  socket_data 
)
void socket_construct ( struct Socket newsock,
struct Server srv,
struct SocketMethods type,
int  fd,
int  isListening,
enum SocketID  socketID,
void *  socket_data 
)
void socket_ctor_def ( struct Socket sock,
struct Server srv,
int  fd,
int  isListening,
enum SocketID  socketID,
void *  data 
)
void socket_dtor_def ( struct Socket sock)
void socket_free_rcvbuf ( struct Socket sock)
static int socket_is_connected ( struct Socket sock)
inlinestatic

References Socket::connecting.

int socket_realloc_recvbuf ( struct Socket sock,
int  len 
)
int socket_send ( struct Socket sock,
const char *  buf,
int  len 
)
int socket_send_blocking ( struct Socket sock,
const char *  buf,
int  len 
)
int socket_send_fast_cross_thread ( struct Socket sock,
const char *  buf,
int  len 
)
int socket_send_if_connected ( struct Socket sock,
const char *  buf,
int  len 
)
static void socket_set_recv_pos ( struct Socket sock,
int  pos 
)
inlinestatic

References Socket::recvPos.

void thread_construct ( struct SocketThread thread)
void thread_construct2 ( struct SocketThread thread,
int  createLogSocket 
)
void thread_decl_fork ( struct NetworkDeclaration netDecl,
enum ThreadID  threadID 
)
int thread_init_listen_daemon ( struct SocketThread thread)
int thread_job_timeslice ( struct SocketThread thread)
static void write_lock ( struct Socket sock)
static
static void write_unlock ( struct Socket sock)
static

Variable Documentation

struct SocketMethods FIFOSocketMethods
struct SocketMethods TCPSocketMethods