HawkTracer  0.10.0
tcp_listener.h File Reference
#include <hawktracer/timeline.h>
#include <stddef.h>

Go to the source code of this file.


typedef typedefHT_DECLS_BEGIN struct _HT_TCPListener HT_TCPListener


HT_API HT_TCPListenerht_tcp_listener_register (HT_Timeline *timeline, int port, size_t buffer_size, HT_ErrorCode *out_err)
 Creates a tcp listener and registers it to a timeline. More...
HT_API HT_TCPListenerht_tcp_listener_create (int port, size_t buffer_size, HT_ErrorCode *out_err)
HT_API void ht_tcp_listener_destroy (HT_TCPListener *listener)
HT_API void ht_tcp_listener_callback (TEventPtr events, size_t size, HT_Boolean serialized, void *user_data)
HT_API void ht_tcp_listener_stop (HT_TCPListener *listener)
 Stops listening to new events. More...

Typedef Documentation

◆ HT_TCPListener

typedef typedefHT_DECLS_BEGIN struct _HT_TCPListener HT_TCPListener

Function Documentation

◆ ht_tcp_listener_callback()

HT_API void ht_tcp_listener_callback ( TEventPtr  events,
size_t  size,
HT_Boolean  serialized,
void *  user_data 

◆ ht_tcp_listener_create()

HT_API HT_TCPListener* ht_tcp_listener_create ( int  port,
size_t  buffer_size,
HT_ErrorCode out_err 

◆ ht_tcp_listener_destroy()

HT_API void ht_tcp_listener_destroy ( HT_TCPListener listener)

◆ ht_tcp_listener_register()

HT_API HT_TCPListener* ht_tcp_listener_register ( HT_Timeline timeline,
int  port,
size_t  buffer_size,
HT_ErrorCode out_err 

Creates a tcp listener and registers it to a timeline.

This is a helper function that wrapps ht_tcp_listener_create() and ht_timeline_register_listener_full(). The user can achieve the same result by explicitly creating a listener and registering it to a timeline:

Please note the example above doesn't implement error handling, which would make the code even more complicated.

timelinethe timeline where the listener will be attached to.
portthe port of the TCP server.
buffer_sizea size of the internal buffer.
out_erra pointer to an error code variable where the error will be stored if the operation fails.
a pointer to a new instance of the listener.

◆ ht_tcp_listener_stop()

HT_API void ht_tcp_listener_stop ( HT_TCPListener listener)

Stops listening to new events.

The function is very similar to ht_tcp_listener_destroy() except it does not release the memory allocated for listener object. After stopping the listener, there's no way to resume it. User needs to create another listener and register it for the timeline instead.

listenerthe listener.