picked from max-weller pull request #20

fixed merge conflict with pull request #21
Marking NsSocket as disconnected prior to firing "close" event

When the underlying socket was disconnected, NsSocket would fire its "close" event prior to marking itself as disconnected via the `this.connected` property.  If the listener to the "close" event triggered downstream functions that attempted to call `nssocket.send`, they would not be able to tell that the socket is disconnected, and a low-level *net.js* error would be thrown ("Error: This socket has been ended by the other party").
Merge pull request #30 from genediazjr/master

combined pull pull request #20 and #23