jeudi 13 août 2015

Nodejs - close socket event reason

Based on the documentation for net module it says that:

Emitted once the socket is fully closed. The argument had_error is a boolean which says if the socket was closed due to a transmission error.

Also, we know that close event will be triggered after error event always:

Emitted when an error occurs. The 'close' event will be called directly following this event.

I have a few doubts regarding how closing of socket works (more precisely when it can happen). I would like to conclude within the script when "close" event is triggered, which side closed the socket. So if "close" event is triggered on client side does this 100% means that socket is closed by other side (and vice versa)? Or I am missing something?

Is it possible for socket to encounter some kind of error which will trigger "close" event even other side is still running? If that is the case how can i conclude from where (and because of what kind of reason) socket is closed? Is it possible to conclude which one of two sides closed the socket (server or client)?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire