Server application context


Defines

#define IX_TCP_CLIENT_PERMANENT   0

Typedefs

typedef ix_tcp_client_s ix_tcp_client_t
typedef int(*) IX_AST_PACKET_FCT (ix_net_t *pnet)
typedef int(*) IX_CLIENT_CONNECT_FCT (ix_tcp_client_t *pcl)
typedef int(*) IX_CLIENT_REPLY_FCT (ix_tcp_client_t *pcl, unsigned char *sendbuf, int sendbuflen, unsigned char *replybuf, int replybuflen)
typedef int(*) IX_CLIENT_DATA_FCT (ix_tcp_client_t *pcl)
typedef int(*) IX_CLIENT_DISCONNECT_FCT (ix_tcp_client_t *pcl)

Functions

int ix_connect_udp (unsigned short myport)
int ix_connect_tcp (int myport)
int ix_tcp_get_port (void)
ix_adr_tix_tcp_client_getsender (ix_tcp_client_t *pcl)
int ix_tcp_client_getfd (ix_tcp_client_t *pcl)
int ix_tcp_client_isdata (ix_tcp_client_t *pcl)
int ix_tcp_client_cs_enter (ix_tcp_client_t *pcl)
int ix_tcp_client_cs_leave (ix_tcp_client_t *pcl)
int ix_tcp_client_setuserdata (ix_tcp_client_t *pcl, void *data)
void * ix_tcp_client_getuserdata (ix_tcp_client_t *pcl)
int ix_tcp_client_rm_byfd (int fd)
int ix_tcp_client_rm (ix_tcp_client_t *ptcp)
int ix_tcp_client_set_timeout_byfd (int fd, int timeout)
int ix_tcp_client_set_timeout (ix_tcp_client_t *ptcp, int timeout)
int ix_ast_receive (IX_AST_PACKET_FCT fct)
int ix_ast_add_hook (int key, IX_AST_PACKET_FCT hook)
ix_net_tix_receive (void)
int ix_set_client_connect_cb (IX_CLIENT_CONNECT_FCT cb)
int ix_set_client_reply_cb (IX_CLIENT_REPLY_FCT cb)
int ix_set_client_data_cb (IX_CLIENT_DATA_FCT cb)
int ix_set_client_disconnect_cb (IX_CLIENT_DISCONNECT_FCT cb)

Typedef Documentation

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()!

Returns:
  • <=0 net packet shall be cared about (i.e. freed) by ix-thread
  • else: net packet is used for further usage in ast routine

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.

Parameters:
pcl client handle
Returns:
not used

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!

Parameters:
pcl client handle
Returns:
  • <=0 the connection to client will be closed

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.

Parameters:
pcl client handle
Returns:
not used

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

Parameters:
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
Returns:
  • Length of data you have written to replybuf
  • <0 Error

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.


Function Documentation

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()!

Parameters:
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 
Returns:
  • 0: ok
  • else: error

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()!

Parameters:
fct global hook to process net packet
Returns:
  • 0 OK
  • <0 Error

int ix_connect_tcp ( int  myport  ) 

Sets up a ix server for interprocess communication over tcp.

Parameters:
myport TCP/IP port we will listen to
Returns:
  • 0 OK
  • <0 Error

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()!

Returns:
  • received net-packet
  • NULL: Error or empty queue

int ix_set_client_connect_cb ( IX_CLIENT_CONNECT_FCT  cb  ) 

Sets callback to provide info for client connect.

Parameters:
cb client connect callback
Returns:
  • 0 OK
  • else Error

int ix_set_client_data_cb ( IX_CLIENT_DATA_FCT  cb  ) 

Sets callback for receiving stream data.

Parameters:
cb data received callback
Returns:
  • 0 OK
  • <0 Error

int ix_set_client_disconnect_cb ( IX_CLIENT_DISCONNECT_FCT  cb  ) 

Sets callback for client disconnect.

Parameters:
cb client disconnect callback
Returns:
  • 0 OK
  • <0 Error

int ix_set_client_reply_cb ( IX_CLIENT_REPLY_FCT  cb  ) 

Sets callback for synchronous client call.

Parameters:
cb data callback
Returns:
  • 0 OK
  • else Error

int ix_tcp_client_cs_enter ( ix_tcp_client_t pcl  ) 

Enters critical section for client

Parameters:
pcl client handle
Returns:
  • 0 OK
  • else Error

int ix_tcp_client_cs_leave ( ix_tcp_client_t pcl  ) 

Leaves critical section for client

Parameters:
pcl client handle
Returns:
  • 0 OK
  • else Error

int ix_tcp_client_getfd ( ix_tcp_client_t pcl  ) 

Gets socket descriptor of connected tcp-client

Parameters:
pcl client handle
Returns:
  • client socket descriptor
  • <0 error

ix_adr_t* ix_tcp_client_getsender ( ix_tcp_client_t pcl  ) 

Gets client address information

Parameters:
pcl client handle
Returns:
  • client adress
  • NULL error

void* ix_tcp_client_getuserdata ( ix_tcp_client_t pcl  ) 

Gets the userdata of connected tcp-client

Parameters:
pcl client handle
Returns:
  • Userdata
  • NULL: Error

int ix_tcp_client_isdata ( ix_tcp_client_t pcl  ) 

Is it a data stream connection from client?

Parameters:
pcl client handle
Returns:
  • true data stream client connection
  • false no data stream (i.e. net packet connection)

int ix_tcp_client_rm ( ix_tcp_client_t ptcp  ) 

Removes a connected client

Parameters:
ptcp client handle
Returns:
  • 0 OK
  • else Error

int ix_tcp_client_rm_byfd ( int  fd  ) 

Removes a connected client

Parameters:
fd Filedescriptor of client
Returns:
  • 0 OK
  • else Error

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)

Parameters:
timeout in sec, 0 means permanent
ptcp client handle
enable 1 or 0
Returns:
  • 0 OK
  • else Error

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)

Parameters:
fd Filedescriptor of client
timeout in sec, 0 means permanent
Returns:
  • 0 OK
  • else Error

int ix_tcp_client_setuserdata ( ix_tcp_client_t pcl,
void *  data 
)

Sets userdata of connected tcp-client

Parameters:
pcl client handle
data user data
Returns:
  • 0 OK
  • else Error

int ix_tcp_get_port ( void   ) 

Gets the port of tcp connect we are listen to (after tcp_connect)

Returns:
  • port
  • <0 Error


Generated on 4 Mar 2014 for ixtools by  doxygen 1.4.7