Re: Communication between seperate scripts
by BrowserUk (Patriarch) on Apr 06, 2004 at 09:45 UTC
|
For the standalone scenario, you could look at Win32::DDE though the documentation available seems to be very sparse.
You could also try the Win32::API route to the API, but then the problem is one of too much documentation. You might be lucky and turn up a simple example somewhere in the web.
Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
| [reply] [d/l] |
Re: Communication between seperate scripts
by Anonymous Monk on Apr 06, 2004 at 08:48 UTC
|
What is wrong with using networking? If you use a TCP connection for example, a client can connect from either another computer on the internet and/or from the same computer. So in the case where it needs to run standalone, you can run both the client and server on the same machine and simply have the client connect to 127.0.0.1 (on the server port). In a networking situation, you just have your client machine connect to the server machine...
| [reply] |
|
|
If I'm not mistaking, Windows 98 will try to start Dialup networking when you're trying to connect to any IP address, even localhost...
| [reply] |
|
|
No-no, you are mistaken. Try it :)
| [reply] |
|
|
|
|
Re: Communication between seperate scripts
by elwarren (Priest) on Apr 06, 2004 at 15:43 UTC
|
Shared memory or pipes are going to be your best bets if you want to avoid the network. You can attach several processes to a shared chunk of memory and everyone will see the same data at the same time.
I previously wrote an app that basically shares a highspeed serial port over the network to another machine. It used UDP for fast communications, no time for lag. Again, this worked on unix and I know that there has been mention of differences in time precision on windows.
When I researched this project a couple years ago I found several daemons to do port sharing on freshmeat.net. Many of them were written in C and some of them allowed sharing ports between windows and unix machines. There is a standard to do this and these apps had (were supposed to) better signal handling and such. I still ended up using my own because it worked and it was fast and I never had a problem.
Win32::MMF does the work of this for you. You can either address the memory space as a file or you can tie variables. This is probably what you want to do.
I haven't done anything with pipes on windows, just unix, can't comment.
Just checked the perldoc for Win32::MMF and the example shows inter-process signalling. I'd just merge that with your code to read the parallel lines status. Looks like a perfect fit. | [reply] |
|
|
Right. Just what the doctor ordered...now if there was a way to make it work on Win98 machines too, my happiness would be complete :) elwarren++
| [reply] |
|
|
Somewhat dated, but a good in-depth discussion on Windows MMF can be found here: might come useful should you like to try and add Win98 support to Win32::MMF yourself (not everything can be done, but MMF existed already in Win3.11 IIRC). That will require some 'dirty' work with XS and C, but the module author would probably be willing to help.
If I were to do it (given my ability with XS) I'd take the local networking path. All you need for the server program is a port to network repeater:
- a thread reads from the port and writes into some memory buffer (even a perl scalar might do, depends on buffer size); Device-Parallel-Port should probably do what you need (and portably too)
- another thread answers UDP requests with chunks taken from the shared buffer; regular sockets are all you need
It could even be done in a single thread, given that both
processes should complete pretty fast.
Hope that's enough to get you started,
Ant9000
| [reply] |
|
|
|
|
Cache::FileCache is probably what you're looking for.
-Nitrox
| [reply] |
|
|
|
|
Re: Communication between seperate scripts
by jfroebe (Parson) on Apr 06, 2004 at 14:47 UTC
|
Hi Jouke
It sounds what you are looking for is a daemon to handle the actual communication. Basically in your scripts, you would pull in a module that knows how to talk to the daemon (sendto_wheelchair, retrieve, etc).
Unfortunately, in order to avoid using networking, you will have to use windows pipes (NT4, 2k, XP, etc).
I'm a little leery of using perl for the daemon given the time cycles (this sounds like it will require realtime scheduling) as I'm not sure if you can *consistantly* get the level of granularity out of the script.
That said, I have a vague memory of someone asking something similar in the microsoft.com newsgroups a couple years back but it was about running Visual Basic applications to interface with a wheelchair. A quick search on google didn't show anything. Thinking that such an daemon might be of use for many people writing applications for the wheelchairs.
btw, there was a person back in summer that wrote a magazine article about writing perl windows apps for a touch screen display for a disabled family member. For the life of me, I'm unable to remember the name of the magazine.
now, what you are trying to accomplish is closely tied with anyone performing jobs through a parallel port. You may do well to take a look at the 'hobbyist' angle as well.
hope this helps
jason
No one has seen what you have seen, and until that happens, we're all going to think that you're nuts. - Jack O'Neil, Stargate SG-1
| [reply] |
Re: Communication between seperate scripts
by perlsage (Scribe) on Apr 06, 2004 at 12:25 UTC
|
You could provide thoroughly readable data in windows registry, this works. Or your "client" machines could write the information to a central machine... Possibilities are almost limitless <;). | [reply] |
|
|
putting data in the registry would work... *BUT* remember that the registry is a fixed size, once that fills up, you will have to extend it while in safe mode. Not an ideal situation. Jouke would be better off using temp files IMHO.
No one has seen what you have seen, and until that happens, we're all going to think that you're nuts. - Jack O'Neil, Stargate SG-1
| [reply] |
Re: Communication between seperate scripts
by didier (Vicar) on Apr 07, 2004 at 06:43 UTC
|
You should try Win32::MemMap with Tie::Win32MemMap.
The first package can be found on the web site of Steve Lidie:
http://www.lehigh.edu/~sol0/ptk/ptk.html
Sharing can be done through Tie::Win32MemMap which allows sharing a hash between two perl scripts. I don't know where to find this last package but I can send it to you on request.
| [reply] |
Re: Communication between seperate scripts
by chanio (Priest) on Apr 07, 2004 at 04:54 UTC
|
You might be interested in studying the forking process that popfile does with every module that it finds in the modules folder, in order to keep communication between all of them.
Just download the multiplatform distribution. And also the schema found at their wiki help file. The writing is very clear, and it is also very well standarized. | [reply] |