Logo Search packages:      
Sourcecode: libmpdclient version File versions  Download package

bool mpd_async_io ( struct mpd_async async,
enum mpd_async_event  events 
)

Call this function when poll() has returned events for this object's file descriptor. libmpdclient will attempt to perform I/O operations.

Returns:
false if the connection was closed due to an error

Definition at line 247 of file async.c.

References mpd_async::error, MPD_ASYNC_EVENT_ERROR, MPD_ASYNC_EVENT_HUP, MPD_ASYNC_EVENT_READ, MPD_ASYNC_EVENT_WRITE, mpd_async_io(), and MPD_ERROR_CLOSED.

Referenced by mpd_async_io().

{
      bool success;

      assert(async != NULL);

      if (mpd_error_is_defined(&async->error))
            return false;

      if ((events & (MPD_ASYNC_EVENT_HUP|MPD_ASYNC_EVENT_ERROR)) != 0) {
            mpd_error_code(&async->error, MPD_ERROR_CLOSED);
            mpd_error_message(&async->error, "Socket connection aborted");
            return false;
      }

      if (events & MPD_ASYNC_EVENT_READ) {
            success = mpd_async_read(async);
            if (!success)
                  return false;
      }

      assert(!mpd_error_is_defined(&async->error));

      if (events & MPD_ASYNC_EVENT_WRITE) {
            success = mpd_async_write(async);
            if (!success)
                  return false;
      }

      assert(!mpd_error_is_defined(&async->error));

      return true;
}


Generated by  Doxygen 1.6.0   Back to index