net: Improve Socket.prototype.write()

Reviewed-by: Trevor Norris <trev.norris@gmail.com>