Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Socket re-write after failed

Tags:

c

linux

windows

tcp

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.

like image 352
Da Ma Avatar asked Dec 21 '25 06:12

Da Ma


1 Answers

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 :)

like image 63
Nikolai Fetissov Avatar answered Dec 23 '25 23:12

Nikolai Fetissov