473,625 Members | 3,254 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic C to C Data Transfer

Tom
I need my data generating C program on computer #1 to export small
amounts of data (one - 40 byte data structure) periodically (once per
minute) to a C program on computer #2.

I am considering having computer #1 to create two duplicate data files
sequentially. (file_1.dat & file_2.dat).

Then, Computer #2 tries to open file_2.dat and upon failure it opens
file_1.dat.

Due to how small these files are ... one of these two files should
always be "available" for Computer #2.

If either file can not be opened by Computer #1 (Computer #2 is
reading it) ... then that file is simply skipped on that output cycle.
If Computer #2 sees the same time stamp on the most recently read
file_2.dat ... then it reads file_1.dat.

I only know the basics of C programming and hope this can be resolved
within C easily. Both the timing and communication issues are a
challenge for me. Perhaps using a small ram disk would prevent
hammering away on a hard drive? Most likely there is a simple solution
and I am just ignorant of the best approach. Please share how you
would solve this problem. Thanks in advance. :)
Dec 16 '06 #1
38 2959
Tom wrote
(in article <u8************ *************** *****@4ax.com>) :
I need my data generating C program on computer #1 to export small
amounts of data (one - 40 byte data structure) periodically (once per
minute) to a C program on computer #2.

I am considering having computer #1 to create two duplicate data files
sequentially. (file_1.dat & file_2.dat).

Then, Computer #2 tries to open file_2.dat and upon failure it opens
file_1.dat.

Due to how small these files are ... one of these two files should
always be "available" for Computer #2.
It's not on topic for this newsgroup, but a sockets based (or
other network API) solution might make a lot more sense.
If either file can not be opened by Computer #1 (Computer #2 is
reading it) ... then that file is simply skipped on that output cycle.
If Computer #2 sees the same time stamp on the most recently read
file_2.dat ... then it reads file_1.dat.
You seem to be implying that you will ping pong between two
filenames so the app on the other end knows the file has been
updated. Why not simply have the consumer remove the file when
it is done with it, and the producer not write the next version
until it has been removed? Or just keep appending to the
existing file, and have the consumer do blocking reads?
I only know the basics of C programming and hope this can be resolved
within C easily. Both the timing and communication issues are a
challenge for me. Perhaps using a small ram disk would prevent
hammering away on a hard drive?
I don't see how 40 bytes once a minute will hammer on anything.
Odds are the OS fs cache will make it all invisible most of the
time anyway.
Most likely there is a simple solution
and I am just ignorant of the best approach. Please share how you
would solve this problem. Thanks in advance. :)
I would just open some sort of direct communication channel
between the two programs and send the data when needed and skip
the file twiddling.

--
Randy Howard (2reply remove FOOBAR)
"The power of accurate observation is called cynicism by those
who have not got it." - George Bernard Shaw

Dec 16 '06 #2

Tom wrote:
I need my data generating C program on computer #1 to export small
amounts of data (one - 40 byte data structure) periodically (once per
minute) to a C program on computer #2.
<snipped>

I would ask this question in a group dedicated to your platform. Try
to find a group along the lines of comp.unix.progr ammer or
comp.windows.pr ogrammer or similar for your platform.

goose,

Dec 16 '06 #3
On Sat, 16 Dec 2006 13:47:40 GMT, Tom wrote:
>I need my data generating C program on computer #1 to export small
amounts of data (one - 40 byte data structure) periodically (once per
minute) to a C program on computer #2.
I am considering having computer #1 to create two duplicate data files
sequentially . (file_1.dat & file_2.dat).
Then, Computer #2 tries to open file_2.dat and upon failure it opens
file_1.dat.
Due to how small these files are ... one of these two files should
always be "available" for Computer #2.
Can you explain the rationale behind that proceeding?
Dec 16 '06 #4
Tom
On Sat, 16 Dec 2006 15:33:40 GMT, rp*****@yahoo.c om (Roland Pibinger)
wrote:
>On Sat, 16 Dec 2006 13:47:40 GMT, Tom wrote:
>>I need my data generating C program on computer #1 to export small
amounts of data (one - 40 byte data structure) periodically (once per
minute) to a C program on computer #2.
I am considering having computer #1 to create two duplicate data files
sequentiall y. (file_1.dat & file_2.dat).
Then, Computer #2 tries to open file_2.dat and upon failure it opens
file_1.dat.
Due to how small these files are ... one of these two files should
always be "available" for Computer #2.

Can you explain the rationale behind that proceeding?
The scenario is: Several networked machines. Each performing stock
analysis on individual or a small group of financial instruments and
then passing buy/sell instructions to an order placing machine.

The central machine follows/enforces portfolio rules and the results
of the individual instrument analyses must be agglomerated ... but the
individual analyses is too complex and cumbersome for one personal
computer to perform the analysis for every instrument in the
portfolio. Thus I need to use some sort of parallel processing.

The rational is: I am a novice in data transfer methods and I don't
know where to begin. I am not a proficient or professional programmer
by any stretch. HA!! (Big joke.) However, I am better than average in
technical analysis, mathematics, and process design and optimization.

My hope is there is a best method for doing this within C so that I
don't have to venture outside the structured C approach that I like.
Sort of like a common file shared by several computers and programs at
once? Several programs being able to simultaneously have open and to
have write privileges to a single file is not possible? Even with the
usage of SEEK to the file end and flushing the buffer at each write
.... two programs might be writing at the same time. Thus the single
file approach seems to this rookie as impossible. However, each
program on the server computer(s) could write to a specific file set
up for each financial instrument and the central computer could open,
read, and then close these files at a specified timed interval? The
reason to write to two files and thus duplicating the task is an
attempt to avoid timing conflicts. I am looking for functionality and
simplicity over elegance. Although I find the simplest method that is
reliable to be very elegant in my eyes. This level of data transfer
between multiple programs running simultaneously is obviously new
ground for me. As powerful as C is ... there's got to be a best method
and I'd bet the farm (if I had one) that several of the many gurus in
this user group has the knowledge.
Dec 16 '06 #5
Tom <Th********@ear thlink.netwrote :
My hope is there is a best method for doing this within C so that I
don't have to venture outside the structured C approach that I like.
Sort of like a common file shared by several computers and programs at
once? Several programs being able to simultaneously have open and to
have write privileges to a single file is not possible? Even with the
usage of SEEK to the file end and flushing the buffer at each write
...
With all this you are already outside of what the C language comes
with. The C language doesn't deal with much more than a single pro-
gram running on a single machine. When you need communication be-
tween different programs already on the same machine then you must
resort to ways and means your environment allows you to use beside.
If you e.g. are on a machine where the system is POSIX compliant you
could e.g. use the socket interface to communicate between different
processes on the same or on different machines. But this is outside
of the realm of the C language and thus you have to ask these kinds
of questions in a group that deals with your environment - it's not
that people here are unwilling to help but you're asking questions
about baking bread at a carpenters shop and even though the carpen-
ter might know a lot about baking bread he usually will tell you to
go to the bakery next door where (hopefully) the real experts are;-)

Regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\______________ ____________ http://toerring.de
Dec 16 '06 #6
Tom
On 16 Dec 2006 18:49:33 GMT, jt@toerring.de (Jens Thoms Toerring)
wrote:
>Tom <Th********@ear thlink.netwrote :
>My hope is there is a best method for doing this within C so that I
don't have to venture outside the structured C approach that I like.
Sort of like a common file shared by several computers and programs at
once? Several programs being able to simultaneously have open and to
have write privileges to a single file is not possible? Even with the
usage of SEEK to the file end and flushing the buffer at each write
...

With all this you are already outside of what the C language comes
with. The C language doesn't deal with much more than a single pro-
gram running on a single machine. When you need communication be-
tween different programs already on the same machine then you must
resort to ways and means your environment allows you to use beside.
If you e.g. are on a machine where the system is POSIX compliant you
could e.g. use the socket interface to communicate between different
processes on the same or on different machines. But this is outside
of the realm of the C language and thus you have to ask these kinds
of questions in a group that deals with your environment - it's not
that people here are unwilling to help but you're asking questions
about baking bread at a carpenters shop and even though the carpen-
ter might know a lot about baking bread he usually will tell you to
go to the bakery next door where (hopefully) the real experts are;-)

Regards, Jens
Thank you Jens (and others) for directing me towards an operating
system approach. I suppose I must break new ground but I was hoping
for a clever solution without having to learn about sockets and
various other complexities.

Jens' explanation and comparison between bakers and carpenters is
excellent. I understand fully. Still ... I was hoping for an easy way
out.

I guess I will put away my Milwaukee Holeshooter, Porter-Cable
circular saw, and Delta table saw and go shopping for a nice
convection air oven and a Kitchen Aid stand mixer. At least the toys
are still electrical! :)

I am so impressed by the knowledge of some in this group that I can't
begin to blasphemy with the claim of "real" experts being elsewhere
.... but certainly I will find other experts on my journey. I hope they
are not offended after their efforts at educating me and I then tell
them they bake a great cake? Perhaps that baking will remain our
secret. ;) After all, real men construct things ... right? Funny how
both carpenters and bakers wear aprons!! Yeah, I have one too. :))
Dec 16 '06 #7
On Sat, 16 Dec 2006 18:11:49 GMT, Tom wrote:
>The scenario is: Several networked machines. Each performing stock
analysis on individual or a small group of financial instruments and
then passing buy/sell instructions to an order placing machine.
....
>Sort of like a common file shared by several computers and programs at
once?
From that I suppose you machines have access to a common (LAN)
directory which they shall use to exchange data via files?
>Several programs being able to simultaneously have open and to
have write privileges to a single file is not possible?
That depends on the file system (better assume nothing).
>Even with the
usage of SEEK to the file end and flushing the buffer at each write
... two programs might be writing at the same time. Thus the single
file approach seems to this rookie as impossible.
Probably yes.
>However, each
program on the server computer(s) could write to a specific file set
up for each financial instrument and the central computer could open,
read, and then close these files at a specified timed interval? The
reason to write to two files and thus duplicating the task is an
attempt to avoid timing conflicts.
I don't quite understand that. But let's assume we have 2 computers
(pc1, pc2) that have to exchange data via a common directory and shall
not disturb each other. I would define a name and behavior convention:
In the specified common directory pc1 opens only the file with the
name 'to_pc1.dat' and pc2 opens only the file 'to_pc2.dat'. To
exchange data between pc1 and pc2 the following steps need to be
performed:
- pc1 copies the data to the common directory with a temporary file
name
- after copying is finished pc1 renames the file to 'to_pc2.dat'
- pc2 opens (only!) the file 'to_pc2.dat' and changes it
- afterwards pc2 renames the file to 'to_pc1.dat'
- and so on
The point is that pc1 and pc2 never concurrently access (not even
read) the same file and that the rename() function is atomic. You need
to implement some sort of polling to make it work and the approach
isn't very fast. But everything can be done in Standard C (but you
should e.g. look for the sleep() function for polling).

Hope that's relevant to your problem,
Roland Pibinger
Dec 16 '06 #8
In article <45************ **@news.utanet. at>,
Roland Pibinger <rp*****@yahoo. comwrote:
>On Sat, 16 Dec 2006 18:11:49 GMT, Tom wrote:
>>The scenario is: Several networked machines. Each performing stock
analysis on individual or a small group of financial instruments and
then passing buy/sell instructions to an order placing machine.
Is the platform, by any chance, Windows?
If so, try using INI files. Works real well.

Dec 16 '06 #9
Tom wrote:
rp*****@yahoo.c om (Roland Pibinger) wrote:
>Tom wrote:
>>I need my data generating C program on computer #1 to export
small amounts of data (one - 40 byte data structure) periodically
(once perminute) to a C program on computer #2.

I am considering having computer #1 to create two duplicate data
files sequentially. (file_1.dat & file_2.dat). Then, Computer #2
tries to open file_2.dat and upon failure it opens file_1.dat.

Due to how small these files are ... one of these two files
should always be "available" for Computer #2.

Can you explain the rationale behind that proceeding?

The scenario is: Several networked machines. Each performing stock
analysis on individual or a small group of financial instruments
and then passing buy/sell instructions to an order placing machine.

The central machine follows/enforces portfolio rules and the
results of the individual instrument analyses must be agglomerated
... but the individual analyses is too complex and cumbersome for
one personal computer to perform the analysis for every instrument
in the portfolio. Thus I need to use some sort of parallel
processing.

The rational is: I am a novice in data transfer methods and I
don't know where to begin. I am not a proficient or professional
programmer by any stretch. HA!! (Big joke.) However, I am better
than average in technical analysis, mathematics, and process
design and optimization.
Try getting and reading "The Little Book of Semaphores":

<http://greenteapress.c om/semaphores/>

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net>

Dec 17 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1462
by: Prem Soman | last post by:
--0-416482240-1060749044=:93966 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Content-Id: Content-Disposition: inline Note: forwarded message attached. ________________________________________________________________________ Want to chat instantly with your online friends? Get the FREE Yahoo!
1
2390
by: Guinness Mann | last post by:
When you guys talk about "dynamic SQL," to what exactly are you referring? Is dynamic SQL anything that isn't a stored procedure? Specifically, I use ASP.NET to communicate with my SQL Server 2000, using an SqlConnection object to open the database and an SqlCommand object to transfer my SQL text to the database. Is this the "dynamic SQL" that is such a bad thing? What is my alternative? Wait until after my program is working and...
2
20740
by: Fatih BOY | last post by:
Hi, I want to send a report from a windows application to a web page like 'report.asp' Currently i can send it via post method with a context like local=En&Username=fatih&UserId=45&Firm=none But the problem occures when i want to send a data with & sign (i.e: Firm=F&B). I try to solve this problem with using boundary, but i failed. Any idea!?
1
1551
by: Eric Levin | last post by:
I would like to load the Meta Tags in the page from Code: Currently they don't come up. The Source that I have: private void LoadHeaders() { DataSet oDs = new DataSet();
7
17289
by: Mark Waser | last post by:
Hi all, I'm trying to post multipart/form-data to a web page but seem to have run into a wall. I'm familiar with RFC 1867 and have done this before (with AOLServer and Tcl) but just can't seem to get it to work in Visual Basic. I tried coding it once myself from scratch and then modified a class that I found on a newsgroup (referenced below). Both seem to be doing the same thing and neither works (or rather, they seem to work but the...
7
22481
by: Mike Livenspargar | last post by:
We have an application converted from v1.1 Framework to v2.0. The executable references a class library which in turn has a web reference. The web reference 'URL Behavior' is set to dynamic. We added an entry to the executable's .exe.config file to specify the URL, and under the 1.1 framework this worked well. Unfortunately, this is not working under the 2.0 framework. I see in the Reference.cs file under the web service reference the...
0
1901
by: John | last post by:
I am loading my controls dynamically into my asp.net page. When I click on a button on one of those user controls then page reloads and I need to reload the page based on what has happened in the button click. Problem is that the button click is the last thing to fire so I need to reload the page a second time to update the controls based on the logic in the button click. The second time around the page loses its viewstate which stores...
0
2184
by: Rahul | last post by:
Friends, My Question is related to the DTS Package (Dynamic Properties Task). I have a DTS package, In this, I transfer data from a database to another database. Senario -: (DB1.tbl1 --DB2.tbl1) (DB1.tbl2 --DB2.tbl2) (DB1.tbl3 --DB2.tbl3)
1
1705
by: markla | last post by:
Hi, Can someone help me understand why for the code below, when added as a "FieldTemplate" in Dynamic Data, and rendered for a field, does not trigger the "test" function and hence update the label control? (CodeBehind is pretty much same as the original shipped ForeignKey_Edit code, and an event in the codeBehind does not get fired either)
0
8635
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8356
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7184
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6118
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4089
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4193
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2621
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.