Patch sending large data to nonblocking socket issue

When sending large amounts of data using send(), it's possible that
socket_write won't send all of the data. So if we send less than the
total buffer size, we should wait for the socket to become writeable
again using socket_select and then try and write the rest of the data.

Signed-off-by: Ben Agricola <bagricola@squiz.co.uk>