Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added connection check on write method

  • Loading branch information...
commit f862e7c32a6fd74092870e8afd6c124fb03eb19b 1 parent d3f6feb
@kilianc authored
Showing with 5 additions and 0 deletions.
  1. +5 −0 lib/nssocket.js
View
5 lib/nssocket.js
@@ -84,7 +84,12 @@ NsSocket.prototype.connect = function connect(port) {
}
NsSocket.prototype.write = function write(buff) {
+ // if we aren't connected/socketed, then error
+ if (!this.socket || !this.connected) {
+ return this.emit('error', new Error('NsSocket: sending on a bad socket'))
+ }
this.stream.write(buff)
+ return this
}
NsSocket.prototype.send = function send(event, data, callback) {
Please sign in to comment.
Something went wrong with that request. Please try again.