c++ - How do I determine a maximum time needed for TCP socket to die due to intermediate network disconnect? -


I have a program in C ++, which is running on Ubuntu 7.04, using the standard socket API, Which opens a socket on a server. My system stays behind the router

That's my program can be worthless (waiting for the user) I have to figure out how long it can take to get a socket error, once When the program starts, the router stops on the net. ). The router is disconnected from the internet, and then my program tries to communicate on that socket.

Obviously it is not known quickly, because TCP is very efficient in keeping a socket alive under adverse network conditions. This gives TCP many times the opportunity to try again, in many ways, eventually it finally leaves it

I can give to the QA Group (and the customer) that any kind of ' The worst situation 'needs to be installed so that they can check that my code goes into a proper offline state.

(For reference, my program is part of a payment on the pump system for gas stations, and the server system that authorizes payment transactions. It is entirely possible that the net for various types of net For reasons to be cut off, and the customer just wants to know what is expected).

EDIT: I was not clear that no person is waiting on this matter, this system is for back office notation of offline when the proof does not come back in 30 seconds, The transaction is over and people are going to do other things.

EDIT: I came to the conclusion that the question is not really the number of factors involved in deciding how long TCP connection error takes due to a downstream failure in the general case is accurate Devices and failures depend on a simple answer.

You should be able to use:

With:

SO_RCVTIMEO and SO_SNDTIMEO

This link:

Talks about more options that may be of your interest.

Choosing my experience in this one, it is usually a bad idea, even when it seems reasonable, arbitrary time period is usually misbehaving in practice. The general result is that when the environment comes out of the norm, the application becomes useless.

Especially for financial transactions, this should be avoided. Probably a cancel button and some indicate that the transaction taking longer than expected would be a better solution.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -