F.1.7. rascal_dispatcher

This function receives notifications about all events raised by a connection established as a result of execution of functions rascal_connect, rascal_connect_service or rascal_accept. The return value is ignored, unless explicitly stated otherwise.

bool __rascall rascal_dispatcher(
	rrid_t conn,
	const sock_t *peer,
	int event,
	void *context
);

Parameters. 

conn

Request identifier. The application must test this value with the rascal_isok function to see if the operation failed or succeeded.

peer

The address of the remote connection endpoint. If the remote address is not known by the time the event is delivered, this parameter is filled with zeros.

event

The type of the event.

Table F.1. Event types

CodeMeaning
rop_accept

A connection was accepted. To allow the connection, dispatcher must return true; returning false will reject the connection.

The value of context is the one passed to rascal_accept. To change the context identifier for the established connection, use rascal_set_context.

The conn parameter corresponds to the acceepted connection, not to the listening one.

rop_close

The connection is closed. The conn parameter holds the error code. Conenctions that close gracefully are reported with this parameter set to REC_SUCCESS.

rop_connect

The connection attempt is finished. The values of conn and peer correspond to the established connection. The value of context is the one passed to the connecting function.

rop_listen

The library has successfully started accepting incoming connections on the specified address. The handler can still return false to cancel doing so.

rop_read

More data is available in the incoming buffer. The full amount of available data can be determined by a call to rascal_get_rq_size.

For stream oriented connections (established over TCP), the frequency of these events is undetermined and can vary from one byte to iseveral kilobytes having been received.

For datagram connections (established over UDP), this event is delivered for each received datagram.

rop_write

A portion of data was successfully sent to the connection.

For stream oriented connections (established over TCP), the frequency of these events is undetermined and can vary from one byte to the whole buffer having been sent.

For datagram connections (established over UDP), this event is delivered for each sent datagram.

context

The value passed to rascal_connect or other function that establishes a connection, unaltered by the library.