Send data from 1 program to another (on same PC)

  • Thread starter Thread starter Zytan
  • Start date Start date
Z

Zytan

What's the best way?

I could use sockets, but that's overkill. I could use pinvoke'd
SendMessage() like Win32, but I assume there's a C# wrapper for this.
What might it be? The receiving program still needs to respond to a
user message, and how would C# allow this? I've seen some people use
events to send data, but how it works isn't entirely clear to me.

Any thoughts would be appreciated......


Zytan
 
I've seen some people use
events to send data, but how it works isn't entirely clear to me.

Er, I think they were using events to send data between forms of the
SAME program, not between two DIFFERENT programs. So, ignore that
thought.

Zytan
 
What's the best way?

Btw, all I want to do is send a string of text.

http://www.codeproject.com/KB/vb/Send_string_by_message.aspx
This guy provides a way to do it using PostMessage() and events, but
it just seems ugly to build up a string from a bunch of PostMessage()
calls..... I think I'd rather use sockets, although that raises
security issues that PostMessage() does not, and it seems like
overkill.

Zytan
 
http://www.codeproject.com/KB/vb/Send_string_by_message.aspx
This method is flawed. If you have more than one thread sending it,
you get synch errors. This could be fixed, but it makes it much more
complex.

Actually, you just need to look at the window handle in
System.Windows.Forms.Message to distinguish between windows sending
the messages. Since you can't (shouldn't) have multiple threads
running under at the same time using a GUI, anyway, you can (should)
never have the same window sending two messages at once.

Still seems ugly to me, though.

Zytan
 
If both ends are managed and under your control then use Remoting.

Yes, both are managed C# and under my control. I have no idea what
Remoting is, but I'm gonna find out right now. :)

Thanks, Doug.

Zytan
 
If both ends are managed and under your control then use Remoting.

Doug, remoting sounds very powerful and much more easy than sockets...

Can it be used for networking one PC to another PC? Can I have the
same server<-->client communication between two programs using
remoting, both managed & under my control, but just on two PCs instead
of on the same PC?

Zytan
 
Yes
Zytan said:
Doug, remoting sounds very powerful and much more easy than sockets...

Can it be used for networking one PC to another PC? Can I have the
same server<-->client communication between two programs using
remoting, both managed & under my control, but just on two PCs instead
of on the same PC?

Zytan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top