Fix for bug #312.

It might help if we actually sent all of the message, instead of giving up whenever the socket doesn't feel like sending anything.

We were sending partial messages, which is why we were getting funny headers.

This needs a good testing because this caused *massive* problems, but everything is good now.