13 Mart 2019 Çarşamba

TCP Header - RST (Reset) Flag

Giriş
RST (Reset) Flag -  1 bit büyüklüğündedir. Açıklaması şöyle
Connection reset.
Açıklaması şöyle.
"Connection reset by peer" is the TCP/IP equivalent of slamming the phone back on the hook. It's more polite than merely not replying, leaving one hanging. But it's not the FIN-ACK expected of the truly polite TCP/IP converseur.
Bağlantıyı hemen kapatmak için gönderilirTCP Handshake yazısına da bakabilirsiniz.

Kod İle Göndermek
Kod ile bu bayrağın atandığı bir paket göndermek mümkün. Açıklaması şöyle. SO_LINGER değerine 0 verilir ve socket için close() çağrısı yapılır.
Again, according to "UNIX Network Programming" third edition page 202-203, setting SO_LINGER with timeout 0 prior to calling close() will cause the normal termination sequence not to be initiated.

Instead, the peer setting this option and calling close() will send a RST (connection reset) which indicates an error condition and this is how it will be perceived at the other end. You will typically see errors like "Connection reset by peer".

Therefore, in the normal situation it is a really bad idea to set SO_LINGER with timeout 0 prior to calling  close() – from now on called abortive close – in a server application.

However, certain situation warrants doing so anyway:

- If the a client of your server application misbehaves (times out, returns invalid data, etc.) an abortive close makes sense to avoid being stuck in CLOSE_WAIT or ending up in the TIME_WAIT state.

- If you must restart your server application which currently has thousands of client connections you might consider setting this socket option to avoid thousands of server sockets in TIME_WAIT (when calling close() from the server end) as this might prevent the server from getting available ports for new client connections after being restarted.

- On page 202 in the aforementioned book it specifically says: "There are certain circumstances which warrant using this feature to send an abortive close. One example is an RS-232 terminal server, which might hang forever in CLOSE_WAIT trying to deliver data to a stuck terminal port, but would properly reset the stuck port if it got an RST to discard the pending data."

Hiç yorum yok:

Yorum Gönder