Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / May 2006

Tip: Looking for answers? Try searching our database.

IPC advice

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Boni - 13 Mar 2006 13:32 GMT
Dear all,
my application runs in 2 processes on the same machine. Now I need to send a
string from one process to another. One process is managed other is native.
The communication should work on any computer (even with firewalls)
I could write file in one process and read it in other but it seems to be
bad solution.
Could somebody advice me about the simple and fast solution.
Thanks a lot.
Bruno van Dooren - 13 Mar 2006 13:46 GMT
> Dear all,
> my application runs in 2 processes on the same machine. Now I need to send a
[quoted text clipped - 4 lines]
> Could somebody advice me about the simple and fast solution.
> Thanks a lot.

If it has to work on different computers, regardless of firewall settings,
the best option is to use TCP sockets.
one process acts as a server and allows an incoming connection on a specific
port. the other process connects.
Then they can send data to each other.

I have used winsock (which is unmanaged) in the past like this in a windows
service, and it worked great. this way the different computers don't even
have to run the same OS. UNIX and windows can work together that way without
any problem.

You can use winsock in your unmanaged app, and TcpChannel in your managed app.
For unmanaged you can probably also use MFC classes, but i've never used
those.

Signature

Kind regards,
   Bruno.
   bruno_nos_pam_van_dooren@hotmail.com
   Remove only "_nos_pam"

Boni - 13 Mar 2006 13:56 GMT
Dear Bruno,
it does not have to work on different computers, both parts always run on
the same PC. Is there a better option or do you still advice to use sockets?
Thanks a lot,
Marcus Heege - 13 Mar 2006 14:28 GMT
Is the string always of the same size and not too big? If yes, you could
implement a DLL with a shared segment. This is by far the fastest option,
because both processes would effectively share the same physical memory.

> Dear Bruno,
> it does not have to work on different computers, both parts always run on
> the same PC. Is there a better option or do you still advice to use
> sockets?
> Thanks a lot,
Marcus Heege - 13 Mar 2006 14:37 GMT
Look here [1] for a desciption of shared segments. You may also want to read
the documentation of #pragma segment and __declspec(allocate)

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_co
re_how_do_i_share_data_in_my_dll_with_an_application_or_with_other_dlls.3f.asp


> Is the string always of the same size and not too big? If yes, you could
> implement a DLL with a shared segment. This is by far the fastest option,
[quoted text clipped - 5 lines]
>> sockets?
>> Thanks a lot,
Boni - 13 Mar 2006 21:59 GMT
Hi Marcus,
How do I notify another process, that it is time to take data?

> Is the string always of the same size and not too big? If yes, you could
> implement a DLL with a shared segment. This is by far the fastest option,
[quoted text clipped - 5 lines]
>> sockets?
>> Thanks a lot,
Marcus Heege - 13 Mar 2006 22:16 GMT
Look for the documentation of the CreateEvent, SetEvent, WaitForSingleObject
and CloseHandle APIs. An event in as named cross proccess OS object that can
be used for thread serialization. You can see an event like a boolean flag.
The receiver of the data can block its thread (WaitForSingleObject) until
the boolean flag is set to true by the sender thread (SetEvent).

In the MSDN documentation you should find a sample application.

Marcus

> Hi Marcus,
> How do I notify another process, that it is time to take data?
[quoted text clipped - 8 lines]
>>> sockets?
>>> Thanks a lot,
Boni - 13 Mar 2006 22:48 GMT
It does not sound easy :(.
What I need is:
Proc1 requests data (sends address to Proc2)
Proc2 sends data back.
The speed is important.
Is there no easier solution?

> Look for the documentation of the CreateEvent, SetEvent,
> WaitForSingleObject and CloseHandle APIs. An event in as named cross
[quoted text clipped - 20 lines]
>>>> sockets?
>>>> Thanks a lot,
Marcus Heege - 13 Mar 2006 22:59 GMT
> It does not sound easy :(.
> What I need is:
> Proc1 requests data (sends address to Proc2)
> Proc2 sends data back.
> The speed is important.
> Is there no easier solution?

This sounds pretty much like a socket application. Sockets exist in managed
and native APIs. So this should be doable.
AP - 28 May 2006 15:15 GMT
Guys. First of all the programming was never easy. Second: looking for
answers in some goups without having loooked through MSDN is nonsense.
Nobody will fill your head with knowlege you suppose to earn. Moreover. Even
if you think you have picked up some knowlege without earning - you will
fail horobly. Now, READ the MSDN, take examples, create your own application,
compile , run and fail till you fix it.
NOBODY WILL DO IT FOR YOU !!! never.
Bruno van Dooren - 13 Mar 2006 14:29 GMT
> Dear Bruno,
> it does not have to work on different computers, both parts always run on
> the same PC. Is there a better option or do you still advice to use sockets?
> Thanks a lot,

Since you mentioned 'on any computer, regardless of firewall settings' i
assumed that you wanted to use different computers.

The advantage of using sockets is that there is no limitation to what you
can send (types of data, size of data, ...) and you can seamlesly move
applications to different computers.

If you are sure that different computers are never necessary, there are
simpler options like pipes for example.

you can find a good overview here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ipc/base/interp
rocess_communications.asp


Signature

Kind regards,
   Bruno.
   bruno_nos_pam_van_dooren@hotmail.com
   Remove only "_nos_pam"

Boni - 13 Mar 2006 15:23 GMT
Just before I knew nothing about the topic and now I have a full overview.
Thanks a lot Bruno and Marcus for sharing this.
>> Dear Bruno,
>> it does not have to work on different computers, both parts always run on
[quoted text clipped - 14 lines]
> you can find a good overview here:
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ipc/base/interp
rocess_communications.asp

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.