Skip to content

Commit a854ec6

Browse files
committed
Use socket.destroy() not socket.end() on successful connection
When socket.end() is called, a FIN packet is sent however if the other host does not respond the socket will timeout and so this module will report 'closed'. The port is open but the other host is misbehaving. This fix just forces the connection to be destroyed immediately and so means that a successful connection will always result in an 'open' status being reported.
1 parent c747ffa commit a854ec6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Diff for: lib/portscanner.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ portscanner.checkPortStatus = function(port, options, callback) {
7272
// Socket connection established, port is open
7373
socket.on('connect', function() {
7474
status = 'open'
75-
socket.end()
75+
socket.destroy()
7676
})
7777

7878
// If no response, assume port is not listening

0 commit comments

Comments
 (0)