YGetNextEvent(3) event retrieving


#include <Y2/Y.h>
#include <Y2/Ylib.h>

int YGetNextEvent(

        YConnection *connection,

        YEvent *event,

        Boolean block


Specifies the connection to the Y server, obtained by a call to YOpenConnection.
Specifies the event buffer in which to copy the retrieved event values to. event cannot be a NULL pointer. See YEvent for more information about this structure.
If set to True, then specifies that the call should block execution untill an event is obtained.


The YGetNextEvent function gets the next (oldest or latest, if you will) event from the Y server.

If block is set to True, then the call will block untill an event is received.

If block is set to False, then the call will check if there are any events queued. If there is atleast one queued event (being the next/oldest/latest), its values will be coppied to the buffer pointed to by event and the function will return 1. If there were no events in the queue, then the function returns 0.

If you receive a YDisconnect or YShutdown event then the given YConnection con structure's connection would have been closed. You should call YCloseConnection on it immediatly afterwards to deallocated the structure formally.


The YGetNextEvent function returns the number of events received or 0.


#include <stdio.h>
#include <Y2/Y.h>
#include <Y2/Ylib.h>

int main(int argc, char *argv[])

        YEvent event;

        YConnection *con = YOpenConnection(




        if(con == NULL)


        printf("Waiting for event...\n");


                con, &event, True

        ) > 0)


                        "Got event type %i\n",




        YCloseConnection(con, False);