ensure handling input events before eof ones

so that we can consume the input buffer if there is any data pending
when a socket is being closed