lwes_listener.h File Reference


Detailed Description

Functions for listening to LWES events.

Go to the source code of this file.

Data Structures

struct  lwes_listener
 Listens for LWES events. More...

Functions

lwes_listenerlwes_listener_create (LWES_SHORT_STRING address, LWES_SHORT_STRING iface, LWES_U_INT_32 port)
 Create a Listener.
int lwes_listener_add_header_fields (struct lwes_listener *listener, LWES_BYTE_P bytes, size_t max, size_t *len)
 Copy some date from the UDP packet into the event.
int lwes_listener_event_has_name (LWES_BYTE_P bytes, size_t len, LWES_CONST_SHORT_STRING name)
 Determine if a serialized event is of a given type.
int lwes_listener_recv_process_event (struct lwes_listener *listener, struct lwes_event *event, int len)
 This adds headers and deserializes the event.
int lwes_listener_recv (struct lwes_listener *listener, struct lwes_event *event)
 Receive an event from the listener in a blocking manner.
int lwes_listener_recv_by (struct lwes_listener *listener, struct lwes_event *event, unsigned int timeout_ms)
 Receive an event from the listener with a timeout.
int lwes_listener_recv_bytes (struct lwes_listener *listener, LWES_BYTE_P bytes, size_t max)
 Receive bytes from the listener in a blocking manner.
int lwes_listener_recv_bytes_by (struct lwes_listener *listener, LWES_BYTE_P bytes, size_t max, unsigned int timeout_ms)
 Receive bytes from the listener with a timeout.
int lwes_listener_destroy (struct lwes_listener *listener)
 Destroy a Listener.


Function Documentation

struct lwes_listener* lwes_listener_create LWES_SHORT_STRING  address,
LWES_SHORT_STRING  iface,
LWES_U_INT_32  port
 

Create a Listener.

Parameters:
[in] address The multicast ip address as a dotted quad string of the channel to listen on.
[in] iface The dotted quad ip address of the interface to receive messages on, can be NULL to use default.
[in] port The port of the channel to listen on.
See also:
lwes_listener_destroy
Returns:
A newly created listener, use lwes_listener_destroy to free

int lwes_listener_add_header_fields struct lwes_listener listener,
LWES_BYTE_P  bytes,
size_t  max,
size_t *  len
 

Copy some date from the UDP packet into the event.

This will add the following fields to the event as additional attributes

  • SenderIP - the ip address of the sender of the event
  • SenderPort - the port of the sender of the event
  • ReceiptTime - a timestamp of receipt time, as milliseconds since epoch

This should be called immediately after one of

  • lwes_listener_recv
  • lwes_listener_recv_by
  • lwes_listener_recv_bytes
  • lwes_listener_recv_bytes_by in order for the sender ip and port to be accurate

Parameters:
[in] listener The listener which just received the event
[in] bytes The serialized event to add the attributes to
[in] max The maximum size of the serialzed event
[in,out] len The current size of the serialized event
See also:
lwes_listener_recv

lwes_listener_recv_by

lwes_listener_recv_bytes

lwes_listener_recv_bytes_by

Returns:
0 upon success, a negative number upon failure

int lwes_listener_event_has_name LWES_BYTE_P  bytes,
size_t  len,
LWES_CONST_SHORT_STRING  name
 

Determine if a serialized event is of a given type.

This function will compare the name in a serialized event against a given name, if they match 0 is returned, if not a non-zero value is returned

Parameters:
[in] bytes The serialized event
[in] len The current size of the serialized event
[in] name The name to check
Returns:
0 if the serialized event is of type name, non-zero if it is not.

int lwes_listener_recv_process_event struct lwes_listener listener,
struct lwes_event event,
int  len
 

This adds headers and deserializes the event.

This is actually a private function, which will be removed next major version bump of lwes.

Parameters:
[in] listener the listener which just received the event
[out] event the event object to deserialize into
[in] len the size of the serialized event waiting in the listener
Returns:
0 on success, a negative number on failure

int lwes_listener_recv struct lwes_listener listener,
struct lwes_event event
 

Receive an event from the listener in a blocking manner.

Parameters:
[in] listener the listener to receive the event from
[out] event the event to fill out
Returns:
0 on success, a negative number on failure

int lwes_listener_recv_by struct lwes_listener listener,
struct lwes_event event,
unsigned int  timeout_ms
 

Receive an event from the listener with a timeout.

Parameters:
[in] listener the listener to receive the event from
[out] event the event to fill out
[in] timeout_ms the maximum amount of time to wait for an event
Returns:
0 on success, a negative number on failure

int lwes_listener_recv_bytes struct lwes_listener listener,
LWES_BYTE_P  bytes,
size_t  max
 

Receive bytes from the listener in a blocking manner.

This returns the raw bytes and returns them, it will not add header fields nor deserialize the event. This is useful if you want to journal without the cost of deserialization.

Parameters:
[in] listener the listener to receive the bytes from
[out] bytes the byte array to write into
[in] max the maximum number of bytes to write into the bytes array
Returns:
the number of bytes read on success, a negative number on failure

int lwes_listener_recv_bytes_by struct lwes_listener listener,
LWES_BYTE_P  bytes,
size_t  max,
unsigned int  timeout_ms
 

Receive bytes from the listener with a timeout.

This returns the raw bytes and returns them, it will not add header fields nor deserialize the event. This is useful if you want to journal without the cost of deserialization.

Parameters:
[in] listener the listener to receive the bytes from
[out] bytes the byte array to write into
[in] max the maximum number of bytes to write into the bytes array
[in] timeout_ms the maximum amount of time to wait for bytes
Returns:
the number of bytes read on success, a negative number on failure

int lwes_listener_destroy struct lwes_listener listener  ) 
 

Destroy a Listener.

Parameters:
[in] listener The listener to destroy by freeing all of it's used memory.
Returns:
0 on success, negative number on failure


Generated on Thu Aug 21 07:18:55 2008 for lwes by  doxygen 1.4.6