libssh provides a method to query what events an external event loop should poll for: ssh_get_poll_flags:
A bitmask including SSH_READ_PENDING or SSH_WRITE_PENDING. For SSH_READ_PENDING, your invocation of poll() should include POLLIN. For SSH_WRITE_PENDING, your invocation of poll() should include POLLOUT.
This is a feature request to add a method to call once the poll has completed:
void ssh_handle_poll_events(ssh_session session, int events)
The events can be
#define SSH_POLLIN SSH_READ_PENDING #define SSH_POLLOUT SSH_WRITE_PENDING #define SSH_POLLERR 0x10