Files on network drives
We have an interesting problem on a server product we have built. A client who has the hosted files on a machine SEPARATE from the server has some network hiccups every now and then. If this happens while the file is reading, we hang on the read. This is a tragedy because it's a server and it brings down the server basically.
Using the older functions such as _fread(), _fopen() etc.
We thought of bringing the file local while we are using it but the problem could still happen when we're copying. Any ideas?
Difficult, not much info.
Put the read in a seperate thread and run a timeout against it in your main thread. If it hangs, (i.e. doesn't finish by the expected time), kill the thread then start another.
Yes I suppose that could work. Anyone have any experience with this sort of problem? Will killing the thread as adrianxw said while reading across the network cause problems with windows networking?
From my experience here, we have very few professional programmers here in comparison to the number of beginners. You might want to bring your question to a newsgroup such as comp.lang.c++ or comp.lang.c++.moderated (or the c forms if the code is written in c).
I guess you're right but I always assumed that there were a few pros mixed in. Yeah, I've heard beginners answer questions that they clearly know nothing about but it's the most active programming board I've found so far. (my company does not have a newsgroup server available to me while I'm at work)
Will killing the thread as adrianxw said while reading across the network cause problems with windows networking?
Not if it is handled properly. The application I worked on was receiving files via a wireless network from buses. The network connection was established once the bus picked up the base station signal and the various transfer protocols began. Trouble is, the bus driver could decide to drive out whenever he felt he was ready, regardless of the state of the transfer process.
I had each transfer session running in it's own thread with a central controller thread timing out sessions which seemed to have died.
There were a few hoops to jump through, but it worked like a charm in the end, (and remember, this was a dark basement, i.e. unattended operation - had to run by itself for months at a time).
Yes. It can be done.