AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Communication across a network?

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
TheGood



Joined: 30 Jul 2007
Posts: 580

PostPosted: Tue Mar 09, 2010 3:09 am    Post subject: Communication across a network? Reply with quote

Hi,

This is more of a Windows-related question than AHK.

It's easy enough to communicate between two separate scripts when they're running on the same machine using WM_APP or WM_COPYDATA. But what about two scripts running on different machines on the same network? They are in the same workgroup and are also attached through SMB. For now, what I'm doing is "communicating" through the creation, monitoring and deletion of files both scripts can access, but obviously it's not very efficient.

Any ideas?
Back to top
View user's profile Send private message Visit poster's website
Leef_me



Joined: 08 Apr 2009
Posts: 5336
Location: San Diego, California

PostPosted: Tue Mar 09, 2010 3:36 am    Post subject: Re: Communication across a network? Reply with quote

TheGood wrote:
For now, what I'm doing is "communicating" through the creation, monitoring and deletion of files both scripts can access, but obviously it's not very efficient.

Any ideas?
Can you be more specific about what you are trying to communicate between the two?

The reason I ask, is because every communication method has overhead.

If you want to send small amounts of data, the method you describe using has advantages.

As an analogy, thing of the smallest Ahk program that you can possible write. It doesn't even have to do anything useful.
If you compile it, it still takes about 200k of program code in the compressed EXE.

In contrast, I wrote myself a simple filesearch program and it is only 203kb.

I did read about a program called Synergy http://synergy2.sourceforge.net/
that can share mouse/keyboard/>>>clipboard<<< across systems
Back to top
View user's profile Send private message
TheGood



Joined: 30 Jul 2007
Posts: 580

PostPosted: Tue Mar 09, 2010 3:54 am    Post subject: Reply with quote

Well, I mostly want to send commands, in the same way as you would send a WM_APP message. So not really user content. I understand what you mean about the overhead though.

My problem with the file monitoring technique is that one of the two script would have to constantly check if a file exists, and because I need it to be responsive, I have to make it do the check at least 5 times per second. But this is on a machine that runs 24/7. So... the overhead charge might be too elevated.

One solution would be to use the directory change notifications API, but I'm not sure that would just transfer the burden of doing a file check on the OS (might be worth it if it does it in a more efficient manner).
Back to top
View user's profile Send private message Visit poster's website
Leef_me



Joined: 08 Apr 2009
Posts: 5336
Location: San Diego, California

PostPosted: Tue Mar 09, 2010 5:44 am    Post subject: Reply with quote

I tried a solution to your problem but I am having intermitent success.
It works like a charm in Win_vista, but has string result in Win_xp.
Even stranger still is no file write between systems (in enabled directory write so I could copy files, but maybe that isn't enough for running programs) Hmm..

Because of the errant behavior between systems vista vs XP I posted in a new thread. You can have a look at the scripts if you want to try them.
http://www.autohotkey.com/forum/viewtopic.php?t=55484
Back to top
View user's profile Send private message
TheGood



Joined: 30 Jul 2007
Posts: 580

PostPosted: Tue Mar 09, 2010 5:56 am    Post subject: Reply with quote

Hey Leef_me,

Thanks for the attempt! I just found WatchDirectory() by HotKeyIt, which looks like it's what I need (I was about to start wrapping ReadDirectoryChangesW myself before I thought of looking it up on AHK first... what a crazy function!). I'll be testing it (to see how "responsive" it is).
Back to top
View user's profile Send private message Visit poster's website
ebpdoug



Joined: 28 Oct 2009
Posts: 22

PostPosted: Thu Jul 15, 2010 1:35 am    Post subject: Reply with quote

For simple things, a couple of alternatives to the more elaborate TCP socket methods include "named pipes" and "mailslots". Either of these can be used to communicate between processes on the same computer or on different computers on a network (for use on same computer, part of string used is \\.\, for use between computers, the client code simply needs to have the dot replaced with the computer name.

The use of "overlapped" IO for pipes (not required, but has some advantages in terms of preventing "blocking" which can make a script into a total zombie if things go wrong) can be a little complex.

Mailslots are "one way", but it is very simple to have a client and a server at "each end". They use UDP (User Datagram Protocol), which is "less reliable" than sockets, but fine for many things (internet video is sent with UDP).

I posted at simple mailslot server and client at (or rather linked to at)
http://www.autohotkey.com/forum/viewtopic.php?t=59920&highlight=mailslot

Both named pipes and mailslots behave like first-in first-out temporary files, so it is very easy to manage data flow.

If you have lots of two way communication to do and "reliability" is important, sockets are probably the best choice.

MSDN has lots of good info at
http://msdn.microsoft.com/en-us/library/aa365574(VS.85).aspx

(There's tons of good stuff at MSDN on things that can be used in AHK by mean of DLLCall - the problem for noobs like me is where to start looking)
Back to top
View user's profile Send private message
Z_Gecko
Guest





PostPosted: Thu Jul 15, 2010 1:52 am    Post subject: Reply with quote

a nice sum-up on some of the possible options, but
note that TheGood has created a very nice WinSock-library since his request:
http://www.autohotkey.com/forum/topic58183.html

btw. ebpdoug could you please update your top-post of your Mailslots-thread with the scripts itself?
Back to top
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group