Macros | Typedefs | Functions
nm_dgram_client.h File Reference

Datagram based network message client. More...

Macros

#define VTM_NM_DGRAM_CL_OPT_RECV_TIMEOUT   1
 

Typedefs

typedef struct vtm_nm_dgram_client vtm_nm_dgram_client
 

Functions

VTM_API vtm_nm_dgram_client * vtm_nm_dgram_client_new (enum vtm_socket_family fam)
 
VTM_API void vtm_nm_dgram_client_free (vtm_nm_dgram_client *cl)
 
VTM_API int vtm_nm_dgram_client_set_opt (vtm_nm_dgram_client *cl, int opt, const void *val, size_t len)
 
VTM_API int vtm_nm_dgram_client_send (vtm_nm_dgram_client *cl, vtm_dataset *msg, struct vtm_socket_saddr *saddr)
 
VTM_API int vtm_nm_dgram_client_recv (vtm_nm_dgram_client *cl, vtm_dataset *msg, struct vtm_socket_saddr *saddr)
 

Macro Definition Documentation

#define VTM_NM_DGRAM_CL_OPT_RECV_TIMEOUT   1

expects unsigned long, value is millisceonds

Function Documentation

VTM_API vtm_nm_dgram_client* vtm_nm_dgram_client_new ( enum vtm_socket_family  fam)

Creates a new client.

Returns
the created client which can be used in the other functions
NULL if an error occured
VTM_API void vtm_nm_dgram_client_free ( vtm_nm_dgram_client *  cl)

Releases the client and all allocated resources.

After this call the client pointer is no longer valid.

Parameters
clthe client that should be released
VTM_API int vtm_nm_dgram_client_set_opt ( vtm_nm_dgram_client *  cl,
int  opt,
const void *  val,
size_t  len 
)

Sets one of the possible options.

The possible options are macros starting with VTM_NM_DGRAM_CL_OPT_.

Parameters
clthe client where the option should be set
optthe option that should be set
valpointer to new value of the option
lensize of the value
Returns
VTM_OK if the option was successfully set
VTM_E_NOT_SUPPORTED if the given option or the value format is not supported
VTM_ERROR if an error occured
VTM_API int vtm_nm_dgram_client_send ( vtm_nm_dgram_client *  cl,
vtm_dataset msg,
struct vtm_socket_saddr saddr 
)

Sends a message to given destination adress.

Parameters
clthe client
msgthe dataset containing the message values
saddrthe destination adress
Returns
VTM_OK if the message was successfully sent
VTM_E_IO_UNKNOWN or VTM_ERROR if an error occured
VTM_API int vtm_nm_dgram_client_recv ( vtm_nm_dgram_client *  cl,
vtm_dataset msg,
struct vtm_socket_saddr saddr 
)

Tries to receive a message.

Parameters
clthe client
[out]msgthe dataset where the received message is stored
[out]saddrif not NULL the source adress is stored here
Returns
VTM_OK if a message was successfully received
VTM_E_TIMEOUT if the timeout elapsed and no message was received
VTM_E_IO_UNKNOWN or VTM_ERROR if an error occured