Computing.Net > Forums > Programming > Alerting programs

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

Alerting programs

Reply to Message Icon

Original Message
Name: Daemon Rose
Date: November 11, 2003 at 13:11:57 Pacific
Subject: Alerting programs
OS: WinXp Pro
CPU/Ram: AMD 2200, 256
Comment:

Alright, this is a little vague but I hope someone knows what I'm talking about. How difficult (ie - possible :) is it to get say a CGI script that is attached to a webpage to alert a running program that was coded in C++? Basically I'm wondering how I would go about passing data from a webpage document to a seperate C++ program that would be running in the background (note - I have little/no experience with win API, is that what would be used to do this?).
I know one way this could be done would be to simply add the information to a .txt file (and on the other end constantly monitor the size of the file) but this is tedious (not to mention the fact that restricting access to the file (semaphores and all) would be tricky). Is their a fairly easy way to get, say a Java program to pass information to a totally seperate C++ program? Thanks for any help/links.


Report Offensive Message For Removal


Response Number 1
Name: Daemon Rose
Date: November 11, 2003 at 13:18:20 Pacific
Reply:

Alright, looking at the above it might not be all that clear.
Basically how would one go about writing a program that allows text-entry on/in a web page, and can pass that text information of to a C++ client running in the background.
I was just looking at Using Memory Mapped files and JNI to do this (argghhh), I'm hoping that maybe there is an easier way (perhaps everything could be written in C++....ah I don't know). Never done any server/html development before so not sure what C++ would be capable off in terms of interaction with an .HTML document. Any pointers (anyone have any idea what I'm talking about :)


Report Offensive Follow Up For Removal

Response Number 2
Name: anonproxy
Date: November 11, 2003 at 14:33:36 Pacific
Reply:

"How difficult (ie - possible :) is it to get say a CGI script that is attached to a webpage to alert a running program that was coded in C++"

Better question - how insecure would that be? And this is on Windows.

"this is tedious"

Well, this is linear message passing. It's always tedious.

This is why J2EE and .NET exist. They (more easily) allows this kind of communication in an OO model, particularly in n-tier architectures. When I say n-tier, I am refering to the essential component steps in the transaction (logical or physical). The web browser and web server would be (in loose terms) a 2-tier architecture. A browser, server, and database would be 3-tier (very common).

The simplest way is to place data your data in a third tier. You mentioned a text file. That would be the filesystem (meaning overhead). A better way is a database (much more controlled).

You want to keep these components seperate. Integrating them is not only time-intensive and error-prone, it is also dangerous. If this were a bigger project you would create (or buy) a transaction server, through which you could control in explicit ways interprocess communication over transparent medium (maybe the same localhost, maybe over the Internet).

Aside from the database, there are other ways to communicate between the two processes. The basic way is to make a daemon on the localhost which is listening and waiting for some data from the CGI script. However, this means you have to be very careful about both the script and the daemon - there are a lot of ways to introduce errors in this using C++.

A shared memory scheme might be a little over the top. JNI works, but you have already seen the overhead in that. Additionally an XML-RPC scheme would be too complex as well (it would also require server configuration). Though you might consider writing to an XML file. This would cut out a lot of possible problems with the text file idea. You can get XML document generation and parsing support in many languages.

Still, I would go with the database and have a seperate token. The token alerts the process by some oddball method to query the database (or read the file, etc.). The simplest token is some packet sent to a some port the C++ process is listening on. The C++ process gets the syn, maybe sends an ack, for example. Then the query is performed. You could also take a framework like JNI, and cheat and pass your token through that. It would be a waste of resources (and overkill) to be sure, but it would also solve the problem.

It really depends on the level of interoperability the two processes need. If it is just a one-way pass, most things will work well. If it is some two-way communication and maybe negotiation, you need a better hackjob or an actual framework.

Or, you could explore the possibility of evoking the C++ process as CGI or in the CGI script. The practicality of doing this should be very apparent (i.e. you immediately see its a good option or it is out of the question).



Report Offensive Follow Up For Removal

Response Number 3
Name: Daemon Rose
Date: November 12, 2003 at 07:36:10 Pacific
Reply:

Thanks for the response anonproxy. Basically I have to write a program which communicates between two computers over the internet. Only problem I have is that one of the computers can only be interfaced with using a C++ library provided to me from a satellite dealer. I think the easiest solution (this thing needs to be developed quickly) will simply be to have one program at the central (what would have been the server) location that communicates with both the end user and the satellite computer. Thus I will need to install software at the end users site so that they can communicate with the central node (but hey, it's better than having to go through JNI or the insecurity that would arrise from the CGI port). Now all I need to do is find some good TCP/IP libaries for C++ (Code Project & google here I come) :)


Report Offensive Follow Up For Removal

Response Number 4
Name: anonproxy
Date: November 12, 2003 at 18:53:59 Pacific
Reply:

Sourceforge.net
Freshmeat.net


Report Offensive Follow Up For Removal

Response Number 5
Name: saddam
Date: November 17, 2003 at 15:54:26 Pacific
Reply:

In perl alike C, you can use the system() function which makes a call to DOS commands including executables. Java applets are pretty restricted to what they can do. Are you refering to JSP? In any case, the system call can only run on your server and not on the user's machine.

to pass data to the program, create a variable to store something like "myfile <data> <somedata>" and use the name as the argument in the system call.


saddam


Report Offensive Follow Up For Removal







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home



Results for: Alerting programs

How to show HTML code in your posts
    Summary: This is a post to teach you guys that this forum will show your html codes, without you having to type in the special characters, which to me is a bothersome task. All you have to do is throw in some...
www.computing.net/answers/programming/how-to-show-html-code-in-your-posts/9036.html

Code Builder in Access2000
    Summary: Thanks Mark for your reply. But you seem not understand my point. What I need is to send emails from the access itself to others outlooks not the opposite. This is what my colleague wrote in the code...
www.computing.net/answers/programming/code-builder-in-access2000/3104.html

DOS Variable Help
    Summary: Hello Everybody! I need some help to figure out this: i have a .net email applicaction that runs from command prompt, and it attaches a txt file to the email and sends it. You pass the from, to, subje...
www.computing.net/answers/programming/dos-variable-help/15529.html








Which MP3 player do you have?

iPod/iPhone
Zune
Something Else
None


View Results

Poll Finishes In 2 Days.
Discuss in The Lounge
Poll History






Data Recovery Software