05-20-2003, 01:17 PM
I have 2 programs...
1 program that is going to read & write to a file and another one that reads from it...
What is the best way to store and transfer the information to the server drive? I want to store the files on a server machine, because incase one of the machines crashes I can then reboot the computer, open the program and all the data is still there. The files are going to have to be updated every second... so i need something that is quick and not bandwidth greedy.
I have tried to search through the forum but I haven't turned up anything, any help/advice and source code greatly appreciated.
Thanks For Your Help
05-20-2003, 02:54 PM
how much data are you talking about each second?
The potential issue I see here is the manner that you open the file. If you're opening it, writing to it, then closing it, this is good for reducing issues with file sharing to a minimum, however, depending upon the network and server load, the file may not be opened in a second. If you open the file & keep it open, this should help alleviate some of this problem, but if you keep the file open, you may have sharing issues with other apps.
If you could, I would store a local copy with the last minute or so of data, opening it, writing, and closing it. This approach, with a local file, is quite quick - typically only a few milliseconds are needed to do this (assuming not huge amounts of data)
Then, once a minute, switch to a different local file, and trigger an external app to copy the contents of file1 to the server, then delete file1. At the next one minute timer, switch back to the first file, and copy File2 data to the network file & delete file2.
Since the local file will only be open for a few milliseconds every second, the odds of a computer crash occurring while the file is open is pretty remote. And, even if it did, you should still be able to recover all but the current record when the PC is brought back on-line. If it's so critical as to not lose even a single minute of data, to ensure that a drive failure won't cause you to lose the last minutes worth of data, either add a second local drive & write your local file twice, or go to RAID.
05-21-2003, 03:13 AM
Cheers m8.. i might try doing that.. That seems like it might have to be the way it is done.
I will need to look up file copying.. The ini file that I am saving to takes up about 1k... it is not much at all. it use to be 850k until i got use to using ini files.
The only problem is that I am going to make the program respond in real time. so if you delete then it delte's straight away.
I take it then you just make the copying time of the file shorter maybe every half a second???
05-21-2003, 04:09 PM
creating a 1 K ini file every second & copying the contents off every second to a "master" file in the server seems so inneffecient. Just what is the app doing? Possibly we could suggest a more effecient method of achieving your goals if we know what you are trying to accomplish.
05-22-2003, 07:55 AM
The idea was to replace A BBC acorn machine we have that displays the callers to the presenters in the studio. And replace it with a machine that the operator can use to type in the callers details and look at the history or the caller as well as surf the internet.
The presenters has a screen similar to the operator but without the input side of the call program.
I have uploaded the program before in desperate hope of help:
It works great locally but awful over a network.
Like i said any help appreciated... this is doing my head in right now.
05-22-2003, 09:58 AM
I haven't had a chance to look at this code yet, but are you updating the file on a timed interval, or are you updating on an event? (text box validate, for instance) It seems to me that you would want to make the updates based upon an event, rather than on a timed basis.
The other issue that I see is that the system has the data presentation/transfer intimately tied to the data storage function. Too closely tied, if the storage medium is a server based file. You may want to consider separating these two functions. Possibly use winsock to echo the operator keystrokes to the presenter screen for the current caller, and update the history file once when the entry is complete.
On the presenter screen, possibly have a flag used to toggle the display data source between the current operator entry and the historical record. If the presenter is displaying the current operator entry have IT updating every second.
Exxentially, if presenter app in the current entry mode, you have a chat program. (With the received text going into intermediate buffer variables, rather directly to the textboxes) If the presenter is in the history mode, they can scroll through the history file, but the chat portion is still running, updating the buffer variables, so that when the presenter switches back to the current caller mode, the data is already there.
So, for the current caller mode:
Operator enters data-->Winsock transport to Presenter Variables-->Transfer Variables to Textboxes every second
and in the Presenter History mode
Operator enters data-->Winsock transport to Presenter Variables.
05-22-2003, 10:50 AM
Thanks loquin.. but as a complete novice i must say UGH, lol.
I will need to read up on this and try and get my head around it.
I will try and get some examples from planet-source-code.
Is this easy to do for a complete novice and is it easy to setup?
05-22-2003, 11:59 AM
Winsock is just a little ... different. Not really difficult, once you get the basic concepts.
And, think of it as an opportunity to learn a whole new area of programming :D
BTW, this app would be an excellent application for a database - use MSDE on the server (If the station already has SQL server installed, just add your database to that) or (poor second choice *** in this app) an MS Access file. Each user would establish a connecton to the database when the form (or app) opens, the operator would update the database fields upon the completion (validate event) of a textbox; the presenter could requery every second or two.
In this way, the database itself would handle the details of maintaining the files, and ADO would handle the data transfer. If you are keeping a connection open, the update times should be quick.
The database approach would probably eliminate the requirement for Winsock, but if you want to see the text as it is being typed, character by character, winsock is about the only relatively simple method for doing so.
*** the reason I say that an Access database would be a poor choice in this instance is that in order to get a single record from a table, you have to transfer the entire table contents over the network - there IS no server side processing available with Access. MSDE or SQL server, on the other hand, not only allow server-side processessing (which only returns the selected records,) you can create stored procedures, which are "compiled" the first time they are run, with all subsequent runs of that procedure being even faster.
05-22-2003, 07:23 PM
Thanks m8 for the advice. I think what i might do is now create a database. and use winsock so that it sends a signal to the presenter computer and tells it to update from the file and see how that works... I have been thinking about this now for 48 hours straight and my head is fried.. i will proably wait till later on today and work out what the heck i am going to do now with the existing software.
I might see if i can chane the coding to work with the new ideas for the program.