@@ -276,10 +276,16 @@ if (fds_c[i].revents & POLLOUT) { num = [OFNumber numberWithInt: fds_c[i].fd]; stream = [fdToStream objectForKey: num]; [delegate streamDidBecomeReadyForReading: stream]; } + + if (fds_c[i].revents & POLLERR) { + num = [OFNumber numberWithInt: fds_c[i].fd]; + stream = [fdToStream objectForKey: num]; + [delegate streamDidReceiveException: stream]; + } fds_c[i].revents = 0; } #else # ifdef FD_COPY @@ -299,10 +305,20 @@ for (i = 0; i < count; i++) { int fd = [cArray[i] fileDescriptor]; if (FD_ISSET(fd, &readfds_)) [delegate streamDidBecomeReadyForReading: cArray[i]]; + + if (FD_ISSET(fd, &exceptfds_)) { + [delegate streamDidReceiveException: cArray[i]]; + + /* + * Prevent calling it twice in case the fd is in both + * sets. + */ + FD_CLR(fd, &exceptfds_); + } } cArray = [writeStreams cArray]; count = [writeStreams count]; @@ -309,10 +325,13 @@ for (i = 0; i < count; i++) { int fd = [cArray[i] fileDescriptor]; if (FD_ISSET(fd, &writefds_)) [delegate streamDidBecomeReadyForWriting: cArray[i]]; + + if (FD_ISSET(fd, &exceptfds_)) + [delegate streamDidReceiveException: cArray[i]]; } #endif [pool release];