Merge pull request #3603 from ninjarobot/socket-write