Prosody events on Linux

A Prosody event is described in Prosody events.

Events on Linux:

The poll() function can be used with Prosody events. A tSMEventId is a structure with the following fields:

These can be used to construct a struct pollfd for use with poll() as follows:

void event_to_pollfd(struct pollfd *pfd, tSMEventId ev)
{
	pfd->fd = ev.fd;
	pfd->events = ev.mode;
}

When poll() returns, it indicates that the event is set by a non-zero value in the revents field. An application should not rely on particular bits, since that makes it harder to port the application to Microsoft Windows, which does not return any equivalent detail from WaitForMultipleObjects(). However, for debugging purposes, it is useful to know exactly what the revents field can indicate. The following bits may be set in the revents field:

POLLIN
The channel has data ready to be read. This can only occur if the type of the tSMEventId is kSMEventTypeReadData.
POLLOUT
The channel has space for more data to be written. This can only occur if the type of the tSMEventId is kSMEventTypeWriteData.
POLLPRI
The channel may have a status change to report. The appropriate API function (e.g. sm_replay_status()) should be called. This is also the value used to report events such as the detection of a digit.
POLLHUP
The channel does not have any operation in progress.