Fixes socket being closed when it has send data buffered.
Merge branch 'sendfix'