trywrite

March 26, 2020 Contributors

Name

trywrite — Write a string of buflen bytes for an event

Synopsis

#include "ec_growbuf.h"

| int **trywrite** ( | event, |   |
|   | buffer, |   |
|   | buflen); |   |

Event * <var class="pdparam">event</var>;
const char * <var class="pdparam">buffer</var>;
int <var class="pdparam">buflen</var>;

Description

Write a string of buflen bytes for an event.

Note

This function assumes that the event closure is an “accept_construct”.

Note

All events are assumed to be non-blocking, so the write semantics are non-blocking.

A sample call:

i = trywrite(event, ".\r\n", 3)

Parameters

event

An event.

buffer

The string to write.

buflen

The length of buffer, in bytes.

Return Values

This function returns 1 on success and 0 on failure.

Threading

It is only legal to call this function in the Scheduler thread.

See Also

trywritef, minimal_tryread_construct_free, and tryread_until