typedef int( *) IX_AST_PACKET_FCT(ix_net_t *pnet) |
Callback for asynchronous client net message: Provide this callback with ix_ast_reveive or ix_ast_add_hook to process a net packet when it is received. Note: Don't mix it with ix_receive()!
typedef int( * ) IX_CLIENT_CONNECT_FCT(ix_tcp_client_t *pcl) |
Callback for client connect: When client connects to server and this callback is set, it provides the application context with handle of connected clients.
pcl | client handle |
typedef int( * ) IX_CLIENT_DATA_FCT(ix_tcp_client_t *pcl) |
Callback for client data message: It is called when data is availabe in stream send by some client. You have to read the data from socket and you should put the data to some message queue to process it in your main application. Note: You must not block processing in that callback!
pcl | client handle |
typedef int( * ) IX_CLIENT_DISCONNECT_FCT(ix_tcp_client_t *pcl) |
Callback for client disconnect: When client disconnects form server and the callback is set this function is called.
pcl | client handle |
typedef int( * ) IX_CLIENT_REPLY_FCT(ix_tcp_client_t *pcl, unsigned char *sendbuf, int sendbuflen, unsigned char *replybuf, int replybuflen) |
Callback for synchronous client call: When server receives a message send with ix_send() by some client and a callback in the server is set with ix_set_client_reply_cb(), the callback-function is called to set up the reply to the server. Note: The client is blocked in ix_send() till the server replies, so no time consuming task or blocking should performed in the callback
pcl | client handle | |
sendbuf | the client send message | |
sendbuflen | length of the client send message | |
replybuf | the buffer you have to fill with your reply | |
replybuflen | the maximal length of the reply buffer |
typedef struct ix_tcp_client_s ix_tcp_client_t |
Client object for TCP connections in server context. It handles net packet connections for packet oriented messages over tcp-socket as well as data stream connections for raw stream data over tcp-socket.
int ix_ast_add_hook | ( | int | key, | |
IX_AST_PACKET_FCT | hook | |||
) |
Sets user defined hook functions for certain kinds of net packets. Note: Do not mix this function with ix_ast_receive() or ix_receive()!
key | user key to distinguish net packets | |
hook | user defined hook function to be called when net packet with flag set to key is received (ix_netinfo_t, ix_net_setinfo()) | |
hook |
int ix_ast_receive | ( | IX_AST_PACKET_FCT | fct | ) |
Set global hook function to process received net packets (AST: Asynchronous System Trap). Note: Do not mix this function with ix_ast_add_hook() or ix_receive()!
fct | global hook to process net packet |
int ix_connect_tcp | ( | int | myport | ) |
Sets up a ix server for interprocess communication over tcp.
myport | TCP/IP port we will listen to |
int ix_connect_udp | ( | unsigned short | myport | ) |
Depreciated
ix_net_t* ix_receive | ( | void | ) |
When no hook functions (callbacks) for net packet receiving are set up, any received packet will be queued in the main-receive message queue of the ix-thread. By time of receiving the corresponding event will be triggered. The event id is known to your app by ix_init(), the master ix initialization function. So, if this event is triggered (see ix_evs_wait()) one or more net packets are to eat with ix_receive. Note: The returned packet has to be deallocated with ix_net_free()!
int ix_set_client_connect_cb | ( | IX_CLIENT_CONNECT_FCT | cb | ) |
Sets callback to provide info for client connect.
cb | client connect callback |
int ix_set_client_data_cb | ( | IX_CLIENT_DATA_FCT | cb | ) |
Sets callback for receiving stream data.
cb | data received callback |
int ix_set_client_disconnect_cb | ( | IX_CLIENT_DISCONNECT_FCT | cb | ) |
Sets callback for client disconnect.
cb | client disconnect callback |
int ix_set_client_reply_cb | ( | IX_CLIENT_REPLY_FCT | cb | ) |
Sets callback for synchronous client call.
cb | data callback |
int ix_tcp_client_cs_enter | ( | ix_tcp_client_t * | pcl | ) |
Enters critical section for client
pcl | client handle |
int ix_tcp_client_cs_leave | ( | ix_tcp_client_t * | pcl | ) |
Leaves critical section for client
pcl | client handle |
int ix_tcp_client_getfd | ( | ix_tcp_client_t * | pcl | ) |
Gets socket descriptor of connected tcp-client
pcl | client handle |
ix_adr_t* ix_tcp_client_getsender | ( | ix_tcp_client_t * | pcl | ) |
Gets client address information
pcl | client handle |
void* ix_tcp_client_getuserdata | ( | ix_tcp_client_t * | pcl | ) |
Gets the userdata of connected tcp-client
pcl | client handle |
int ix_tcp_client_isdata | ( | ix_tcp_client_t * | pcl | ) |
Is it a data stream connection from client?
pcl | client handle |
int ix_tcp_client_rm | ( | ix_tcp_client_t * | ptcp | ) |
Removes a connected client
ptcp | client handle |
int ix_tcp_client_rm_byfd | ( | int | fd | ) |
Removes a connected client
fd | Filedescriptor of client |
int ix_tcp_client_set_timeout | ( | ix_tcp_client_t * | ptcp, | |
int | timeout | |||
) |
Set client inacitivity timeout (as default clients are not permanent, i.e. client is removed after 300 seconds of inactivitiy)
timeout | in sec, 0 means permanent | |
ptcp | client handle | |
enable | 1 or 0 |
int ix_tcp_client_set_timeout_byfd | ( | int | fd, | |
int | timeout | |||
) |
Set client inacitivity timeout (as default clients are not permanent, i.e. client is removed after 300 seconds of inactivitiy)
fd | Filedescriptor of client | |
timeout | in sec, 0 means permanent |
int ix_tcp_client_setuserdata | ( | ix_tcp_client_t * | pcl, | |
void * | data | |||
) |
Sets userdata of connected tcp-client
pcl | client handle | |
data | user data |
int ix_tcp_get_port | ( | void | ) |
Gets the port of tcp connect we are listen to (after tcp_connect)