Skip to content

Commit 68a981d

Browse files
committed
Get addresses before touching state
1 parent 534a3a9 commit 68a981d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -333,13 +333,13 @@ exports.Socket = class TCPSocket extends Duplex {
333333
return
334334
}
335335

336+
this._localAddress = binding.address(this._handle, true)
337+
this._remoteAddress = binding.address(this._handle, false)
338+
336339
this._state |= constants.state.CONNECTED
337340
this._state &= ~constants.state.CONNECTING
338341
this._continueOpen()
339342

340-
this._localAddress = binding.address(this._handle, true)
341-
this._remoteAddress = binding.address(this._handle, false)
342-
343343
this.emit('connect')
344344
}
345345

@@ -595,11 +595,11 @@ exports.Server = class TCPServer extends EventEmitter {
595595
try {
596596
binding.accept(this._handle, socket._handle)
597597

598-
socket._state |= constants.state.CONNECTED
599-
600598
socket._localAddress = binding.address(socket._handle, true)
601599
socket._remoteAddress = binding.address(socket._handle, false)
602600

601+
socket._state |= constants.state.CONNECTED
602+
603603
this._connections.add(socket)
604604

605605
if (this._keepAlive) socket.setKeepAlive(this._keepAlive, this._keepAliveInitialDelay)

0 commit comments

Comments
 (0)