Wrap response socket for platform compatibility.

This PR was rebased in a new branch. It is identical to #289, except for renaming the wrapping object.