-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What's the difference between .close()
and .disconnect()
in dgram
Web Socket
#41815
Comments
You're being nominated as collaborator so I'll give you hints instead of a straight up answer to encourage exploration in the code: Disconnect:
Close:
|
|
Apologies for the delayed reply. I had a busy week. |
Here's what I've gathered: Disconnect: Close: So the difference is that |
The 'close' event is emitted after a socket is closed with close(). Once triggered, no new 'message' events will be emitted on this socket A synchronous function that disassociates a connected dgram.Socket from its remote address. Trying to call disconnect() on an unbound or already disconnected socket will result in an The writeup was gotten from https://nodejs.org/api/dgram.html#event-listening |
I think #41815 (comment) is the correct answer. I'm going to close this. Feel free to reopen it if you think there's still something to be solved. |
Description of the problem
I am trying to resolve an issue on nodejs/help.
The user reported getting
Error [ERR_SOCKET_DGRAM_IS_CONNECTED]: Already connected
when reconnecting after deliberately closing the socket connection.I was able to reproduce the issue using
.close()
and I also tried.disconnect()
. In both cases, I encountered different errors when trying to reconnect after (deliberately) closing/disconnecting the socket.Here's what I would like to understand:
Based on the explanation I intend to create a PR to fix the issue (if any) and also add more context to descriptions of
.close()
and.disconnect()
indgram
documentationThe text was updated successfully, but these errors were encountered: