Data Structures | Functions
socket_writer.h File Reference

Buffered writing to a socket. More...

Data Structures

struct  vtm_socket_writer
 

Functions

VTM_API void vtm_socket_writer_reset (struct vtm_socket_writer *sw)
 
VTM_API int vtm_socket_writer_putm (struct vtm_socket_writer *sw, const char *src, size_t len)
 
VTM_API int vtm_socket_writer_puts (struct vtm_socket_writer *sw, const char *str)
 
VTM_API int vtm_socket_writer_putc (struct vtm_socket_writer *sw, char c)
 
VTM_API int vtm_socket_writer_flush (struct vtm_socket_writer *sw)
 

Function Documentation

VTM_API void vtm_socket_writer_reset ( struct vtm_socket_writer sw)

Resets buffer index and error state.

Parameters
swthe writer that should be reset
VTM_API int vtm_socket_writer_putm ( struct vtm_socket_writer sw,
const char *  src,
size_t  len 
)

Write memory chunk.

Parameters
swthe target writer
srcthe pointer to begin of memory chunk
lenthe length of the memory chunk
Returns
VTM_OK if the write was successful
VTM_ERROR or other error code if the call failed OR any previous call already failed and the writer was not reset after the error
VTM_API int vtm_socket_writer_puts ( struct vtm_socket_writer sw,
const char *  str 
)

Write string.

Parameters
swthe target writer
strpointer to NUL-terminated string
Returns
VTM_OK if the write was successful
VTM_ERROR or other error code if the call failed OR any previous call already failed and the writer was not reset after the error
VTM_API int vtm_socket_writer_putc ( struct vtm_socket_writer sw,
char  c 
)

Write single character.

Parameters
swthe target writer
ccharacter to write
Returns
VTM_OK if the write was successful
VTM_ERROR or other error code if the call failed OR any previous call already failed and the writer was not reset after the error
VTM_API int vtm_socket_writer_flush ( struct vtm_socket_writer sw)

All data in buffer is written to socket.

Parameters
swthe target writer
Returns
VTM_OK if the data was successfully written to the socket
VTM_ERROR or other error code if the call failed OR any previous call already failed and the writer was not reset after the error