socket: adding fix for partial fwrites, fixes #21

It's possible for a socket write to require multiple calls to fwrite.
In that case, we want to write only a subsection of the request
rather than the whole request.
Merge branch 'master' of https://github.com/segmentio/analytics-php