Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Send message from C# to C++

Reply
Thread Tools

Send message from C# to C++

 
 
Magdy
Guest
Posts: n/a
 
      06-09-2009
Hello,

I have two applications, one c# and another c++. I want the c# one to
run the c++ application and sends message (ex. string ... certain data
needed to initialize the c++ application) to it.

Please, help me... how to implement that in both sides (C# sends
message & C++ receives it)

Any thoughts, ideas, advice will be highly appreciated.
Thanks!


 
Reply With Quote
 
 
 
 
Camiel
Guest
Posts: n/a
 
      06-09-2009
Couldn't you simply use Process.Start() to start the C++ application
with some command line arguments (the data you want to pass), and pick
up that data from the arguments list to main() in the C++ app?

On Jun 9, 7:38*am, Magdy <magdy....@gmail.com> wrote:
> Hello,
>
> I have two applications, one c# and another c++. I want the c# one to
> run the c++ application and sends message (ex. string ... certain data
> needed to initialize the c++ application) to it.
>
> Please, help me... how to implement that in both sides (C# sends
> message & C++ receives it)
>
> Any thoughts, ideas, advice will be highly appreciated.
> Thanks!


 
Reply With Quote
 
 
 
 
Maxim Yegorushkin
Guest
Posts: n/a
 
      06-09-2009
On Jun 9, 6:38*am, Magdy <magdy....@gmail.com> wrote:

> I have two applications, one c# and another c++. I want the c# one to
> run the c++ application and sends message (ex. string ... certain data
> needed to initialize the c++ application) to it.
>
> Please, help me... how to implement that in both sides (C# sends
> message & C++ receives it)
>
> Any thoughts, ideas, advice will be highly appreciated.


You can redirect standard input and output of your C++ program, so
that it receives commands on its standard input from a C# application,
and writes responses into its standard output, which the C#
application reads.

Or, if the C++ application is a standalone server, you can use TCP
sockets for sending commands and receiving responses.

--
Max
 
Reply With Quote
 
Magdy Wageeh
Guest
Posts: n/a
 
      06-09-2009
On Jun 9, 10:03*am, Camiel <iamcam...@gmail.com> wrote:
> Couldn't you simply use Process.Start() to start the C++ application
> with some command line arguments (the data you want to pass), and pick
> up that data from the arguments list to main() in the C++ app?
>
> On Jun 9, 7:38*am, Magdy <magdy....@gmail.com> wrote:
>
> > Hello,

>
> > I have two applications, one c# and another c++. I want the c# one to
> > run the c++ application and sends message (ex. string ... certain data
> > needed to initialize the c++ application) to it.

>
> > Please, help me... how to implement that in both sides (C# sends
> > message & C++ receives it)

>
> > Any thoughts, ideas, advice will be highly appreciated.
> > Thanks!

>
>


Thanks both of you!
I used the Process & StartInfo in c# and sent data in arguments using
the command line to c++.

very simple, thanks once more.
 
Reply With Quote
 
cr88192
Guest
Posts: n/a
 
      06-11-2009

"Maxim Yegorushkin" <> wrote in message
news:aa5e2446-7e2a-498d-8f49-...
On Jun 9, 6:38 am, Magdy <magdy....@gmail.com> wrote:

> I have two applications, one c# and another c++. I want the c# one to
> run the c++ application and sends message (ex. string ... certain data
> needed to initialize the c++ application) to it.
>
> Please, help me... how to implement that in both sides (C# sends
> message & C++ receives it)
>
> Any thoughts, ideas, advice will be highly appreciated.


<
You can redirect standard input and output of your C++ program, so
that it receives commands on its standard input from a C# application,
and writes responses into its standard output, which the C#
application reads.

Or, if the C++ application is a standalone server, you can use TCP
sockets for sending commands and receiving responses.
>



or, if running within the same process, one can make use of C code (true, or
'extern "C" { ...}') and P/Invoke...

C# -> C, C -> C++

getting things the other way (C++ -> C#) is a little harder AFAIK (not much
real experience with .NET in my case...), although particular .NET VMs are
likely to provide APIs for this case.



 
Reply With Quote
 
Jorgen Grahn
Guest
Posts: n/a
 
      06-14-2009
On Tue, 9 Jun 2009 01:41:39 -0700 (PDT), Maxim Yegorushkin <> wrote:
> On Jun 9, 6:38*am, Magdy <magdy....@gmail.com> wrote:
>
>> I have two applications, one c# and another c++. I want the c# one to
>> run the c++ application and sends message (ex. string ... certain data
>> needed to initialize the c++ application) to it.
>>
>> Please, help me... how to implement that in both sides (C# sends
>> message & C++ receives it)
>>
>> Any thoughts, ideas, advice will be highly appreciated.

>
> You can redirect standard input and output of your C++ program, so
> that it receives commands on its standard input from a C# application,
> and writes responses into its standard output, which the C#
> application reads.


That is usually a bad idea, prone to lockups. (Just *one* of the
directions is usually a good idea, known as popen()).

/Jorgen

--
// Jorgen Grahn <grahn@ Ph'nglui mglw'nafh Cthulhu
\X/ snipabacken.se> R'lyeh wgah'nagl fhtagn!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Socket send functions only allow you to send strings? Ryan Parmeter Ruby 4 09-05-2007 03:29 AM
Mail.SmtpMail.Send won't send to one of my addresses Nathan Sokalski ASP .Net 3 11-23-2005 09:25 PM
Pre-Send Request Headers, Pre-Send Request Content =?Utf-8?B?S2V2aW4gQnVydG9u?= ASP .Net 0 12-31-2004 06:29 PM
How can a window send message to other window Frank ASP .Net 1 12-31-2003 05:47 AM
Does Socket.send send all bytes? Chris Reay Ruby 2 11-04-2003 08:22 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57