--- OLD +++ NEW @@ -322,12 +322,20 @@ if (!FD_ISSET(i, fds)) continue; + /* If we are sending a large amount of data, we might momentarily run out of + send space and get a -1 + EAGAIN when we send. We could handle it ourselves, + or we could just mark the socket as blocking, and the OS will handle it for us. */ + block_socket(i); + fdn = get_fdinfo(fdlist, i); if (fdinfo_send(fdn, msg, size) <= 0) { if (o.debug > 1) logdebug("Error sending to fd %d: %s.\n", i, socket_strerror(socket_errno())); ret = -1; } + + /* Return to its former state when we're done with the send */ + unblock_socket(i); } ncat_log_send(msg, size);