refactoring sendloop for Linux.