# The Event Manager

The Event Manager defines the API to any event loop to be used by libwww for handling events. An event is not strictly defined as it is highly platform dependent and considered out of scope for libwww.

The libwww core does not define any event loop - this is considered part of the application. However, in the libwww application module, you will find two default event loops: one for Unix and one or Windows. They are normally initialized using the libwww profiles which help you setting up libwww for your particular needs.

Libwww is not currently thread safe - it supports what I call pseudo threads which are timed on I/O operations - that is, libwww works very much like X.

If your application is not using anything but traditional blocking sockets then you do not need an event manager at all. In that case, libwww will block on any socket or system call until the process can proceed. It is important to note that certain operations like HTTP PUT and POST, for example, require non-blocking sockets.

The libwww event interface is very simple, it consists of two operations:

1. registering a socket descriptor together with the location in the program, and the current state of the operation (for example `read`). When the event manager at a later point in time gets a notification that the socket has become ready, it can then call libwww with the state saved from the registration and libwww can continue.
2. unregistering a socket descriptor when it is not anymore in a state where it can block.

Registrering an Event Manager