Da Ma
Da Ma

Reputation: 411

Socket re-write after failed

Here is the environment:

client -> router -> server

client will keep writing data to server even if the connection is broken.

Here is steps:

  1. router has some problems, so client will get error message.

  2. router are recovered

Can client write the data to the server as before.

PS: it's a TCP connection.

Upvotes: 3

Views: 119

Answers (1)

Nikolai Fetissov
Nikolai Fetissov

Reputation: 84239

TCP is designed to tolerate temporary failures. Buffering, sequencing, acknowledgements, timeouts and retransmission mechanisms built into TCP would take care of some dropped packets. The ends of the connected TCP stream would just see a delay while route recovers. Client might overflow its socket send buffer and return an error from the send call, and it's up to you how to handle that (waiting, retrying, bailing).

This would not work though if your router is really a NAT firewall, which consumer-grade "routers" usually are.

This would also not work if server software decides to close your connection after some period of perceived inactivity.

I suggest investing some time into understanding TCP/IP a bit more, maybe buying a book :)

Upvotes: 2

Related Questions