473,378 Members | 1,609 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

How to talk with an external console?

I have a full work app (server and client) that talk between two executables
trought Console.WriteLine(); & Console.ReadLine();

I have the source code of the server.

I need to make the client. To do this i have

Console.WriteLine("Hi server");

while (true)
{
String command = "";
try
{
command = Console.ReadLine();
if (command != null)
if(command.Length > 0)
System.Console.WriteLine("Server response: " + command);
}
catch (IOException ex)
{
Console.WriteLine(ex.StackTrace);
outWriter.WriteLine(ex.StackTrace);
}
}

But never can read anything.

I know good how to make a client server with TCP. But with Console appears
to be different.
When is "established" the connection?
Nov 16 '05 #1
7 2937

"~toki" <pedorro77.hotmail.com> wrote in message
news:ed**************@TK2MSFTNGP10.phx.gbl...
I have a full work app (server and client) that talk between two executables trought Console.WriteLine(); & Console.ReadLine(); .... But never can read anything.

I know good how to make a client server with TCP. But with Console appears
to be different.
When is "established" the connection?


As far as I know, different applications cannot communicate through a
console. Do you have some information indicating that they can?
Nov 16 '05 #2
I have the server source in C# and the client is an .exe (made in C)
I see how talk with a "debug windows" of the client.
The client send two tokens to the server.
And the server response with a token (that exists in the source code) with
Console.Write(returnToken);
It works fine.
I can't run the C# server from the MS IDE to stop and debug when the client
send the token.

*The client run the server when it start.

I have tried do it with System.Diagnostic.Process.Start("server.exe") but it
don't work.
"Michael A. Covington" <lo**@www.covingtoninnovations.com.for.address>
escribió en el mensaje news:ei**************@tk2msftngp13.phx.gbl...

"~toki" <pedorro77.hotmail.com> wrote in message
news:ed**************@TK2MSFTNGP10.phx.gbl...
I have a full work app (server and client) that talk between two

executables
trought Console.WriteLine(); & Console.ReadLine();

...
But never can read anything.

I know good how to make a client server with TCP. But with Console appears to be different.
When is "established" the connection?


As far as I know, different applications cannot communicate through a
console. Do you have some information indicating that they can?

Nov 16 '05 #3
Ah! Creo que lo que Ud. intenta es que quiere comunicar con otro proceso
por "standard input" y "standard output". No se' como se hace.

Anyone -- How do you get a process to read and write to another process's
stdin and stdout? If you can?
"~toki" <pedorro77.hotmail.com> wrote in message
news:uo**************@TK2MSFTNGP11.phx.gbl...
I have the server source in C# and the client is an .exe (made in C)
I see how talk with a "debug windows" of the client.
The client send two tokens to the server.
And the server response with a token (that exists in the source code) with
Console.Write(returnToken);
It works fine.
I can't run the C# server from the MS IDE to stop and debug when the client send the token.

*The client run the server when it start.

I have tried do it with System.Diagnostic.Process.Start("server.exe") but it don't work.
"Michael A. Covington" <lo**@www.covingtoninnovations.com.for.address>
escribió en el mensaje news:ei**************@tk2msftngp13.phx.gbl...

"~toki" <pedorro77.hotmail.com> wrote in message
news:ed**************@TK2MSFTNGP10.phx.gbl...
I have a full work app (server and client) that talk between two

executables
trought Console.WriteLine(); & Console.ReadLine();

...
But never can read anything.

I know good how to make a client server with TCP. But with Console appears to be different.
When is "established" the connection?


As far as I know, different applications cannot communicate through a
console. Do you have some information indicating that they can?


Nov 16 '05 #4
Michael,

Both the Process and Console classes have properties and methods to
work with standard input/output/error. You could try some match making
between the two classes. I'm too tired tonight to give it a spin´, but let
us
know how it works out.

HTH,

//Andreas

"Michael A. Covington" <lo**@www.covingtoninnovations.com.for.address> skrev
i meddelandet news:%2****************@TK2MSFTNGP09.phx.gbl...
Ah! Creo que lo que Ud. intenta es que quiere comunicar con otro proceso
por "standard input" y "standard output". No se' como se hace.

Anyone -- How do you get a process to read and write to another process's
stdin and stdout? If you can?
"~toki" <pedorro77.hotmail.com> wrote in message
news:uo**************@TK2MSFTNGP11.phx.gbl...
I have the server source in C# and the client is an .exe (made in C)
I see how talk with a "debug windows" of the client.
The client send two tokens to the server.
And the server response with a token (that exists in the source code) with Console.Write(returnToken);
It works fine.
I can't run the C# server from the MS IDE to stop and debug when the client
send the token.

*The client run the server when it start.

I have tried do it with System.Diagnostic.Process.Start("server.exe")

but it
don't work.
"Michael A. Covington" <lo**@www.covingtoninnovations.com.for.address>
escribió en el mensaje news:ei**************@tk2msftngp13.phx.gbl...

"~toki" <pedorro77.hotmail.com> wrote in message
news:ed**************@TK2MSFTNGP10.phx.gbl...
> I have a full work app (server and client) that talk between two
executables
> trought Console.WriteLine(); & Console.ReadLine();
...
> But never can read anything.
>
> I know good how to make a client server with TCP. But with Console

appears
> to be different.
> When is "established" the connection?

As far as I know, different applications cannot communicate through a
console. Do you have some information indicating that they can?



Nov 16 '05 #5
Pienso que si, consegui el codigo fuente pero no lo puedo compilar.

Here some relevant lines of the client source code. (i don't know C)
/*
* The steps for redirecting child's STDIN:
* 1. Create anonymous pipe to be STDIN for child.
* 2. Create a noninheritable duplicate of write handle,
* and close the inheritable write handle.
*/
/* Create a pipe for the child's STDIN. */
if (! CreatePipe(&hChildStdinRd, &hChildStdinWr, &saAttr, 0)) {
return GetLastError();
}
....
fSuccess = CreateProcess(NULL,
cmdLine, /* command line */
NULL, /* process security attributes */
NULL, /* primary thread security attrs */
TRUE, /* handles are inherited */
DETACHED_PROCESS|CREATE_NEW_PROCESS_GROUP,
NULL, /* use parent's environment */
NULL,
&siStartInfo, /* STARTUPINFO pointer */
&piProcInfo); /* receives PROCESS_INFORMATION */
....

"Michael A. Covington" <lo**@www.covingtoninnovations.com.for.address>
escribió en el mensaje news:%2****************@TK2MSFTNGP09.phx.gbl...
Ah! Creo que lo que Ud. intenta es que quiere comunicar con otro proceso
por "standard input" y "standard output". No se' como se hace.

Anyone -- How do you get a process to read and write to another process's
stdin and stdout? If you can?
"~toki" <pedorro77.hotmail.com> wrote in message
news:uo**************@TK2MSFTNGP11.phx.gbl...
I have the server source in C# and the client is an .exe (made in C)
I see how talk with a "debug windows" of the client.
The client send two tokens to the server.
And the server response with a token (that exists in the source code) with Console.Write(returnToken);
It works fine.
I can't run the C# server from the MS IDE to stop and debug when the client
send the token.

*The client run the server when it start.

I have tried do it with System.Diagnostic.Process.Start("server.exe")

but it
don't work.
"Michael A. Covington" <lo**@www.covingtoninnovations.com.for.address>
escribió en el mensaje news:ei**************@tk2msftngp13.phx.gbl...

"~toki" <pedorro77.hotmail.com> wrote in message
news:ed**************@TK2MSFTNGP10.phx.gbl...
> I have a full work app (server and client) that talk between two
executables
> trought Console.WriteLine(); & Console.ReadLine();
...
> But never can read anything.
>
> I know good how to make a client server with TCP. But with Console

appears
> to be different.
> When is "established" the connection?

As far as I know, different applications cannot communicate through a
console. Do you have some information indicating that they can?



Nov 16 '05 #6
Thanks, it don't work (yet) but i understand where start.

Something like this..

System.Diagnostics.Process p = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo();
info.UseShellExecute = false;
info.CreateNoWindow = false;
info.FileName = app;
info.RedirectStandardOutput = true;
p.StartInfo = info;
p.Start();
p.WaitForExit();
Console.WriteLine( p.StandardOutput.ReadToEnd() );

I will investigate it...

"Michael A. Covington" <lo**@www.covingtoninnovations.com.for.address> escribió en el mensaje news:%2****************@TK2MSFTNGP09.phx.gbl...
Ah! Creo que lo que Ud. intenta es que quiere comunicar con otro proceso
por "standard input" y "standard output". No se' como se hace.

Anyone -- How do you get a process to read and write to another process's
stdin and stdout? If you can?


"~toki" <pedorro77.hotmail.com> wrote in message
news:uo**************@TK2MSFTNGP11.phx.gbl...
I have the server source in C# and the client is an .exe (made in C)
I see how talk with a "debug windows" of the client.
The client send two tokens to the server.
And the server response with a token (that exists in the source code) with
Console.Write(returnToken);
It works fine.
I can't run the C# server from the MS IDE to stop and debug when the

client
send the token.

*The client run the server when it start.

I have tried do it with System.Diagnostic.Process.Start("server.exe") but

it
don't work.
"Michael A. Covington" <lo**@www.covingtoninnovations.com.for.address>
escribió en el mensaje news:ei**************@tk2msftngp13.phx.gbl...

"~toki" <pedorro77.hotmail.com> wrote in message
news:ed**************@TK2MSFTNGP10.phx.gbl...
> I have a full work app (server and client) that talk between two
executables
> trought Console.WriteLine(); & Console.ReadLine();
...
> But never can read anything.
>
> I know good how to make a client server with TCP. But with Console

appears
> to be different.
> When is "established" the connection?

As far as I know, different applications cannot communicate through a
console. Do you have some information indicating that they can?



Nov 16 '05 #7
It works. Here's the code...

System.Diagnostics.Process p = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo();
info.UseShellExecute = false;
info.CreateNoWindow = false;
info.FileName = app; // App filename
info.RedirectStandardOutput = true;
p.StartInfo = info;
p.Start();

p.StandardInput.WriteLine("Hi server. Lets start!!");

while (true)
{
String command = "";
try
{
command = p.StandardOutput.ReadLine();
if (command != null)
if(command.Length > 0)
System.Console.WriteLine(command);
}
catch (IOException ex)
{
// Print an exception to command line and log file
Console.WriteLine(ex.StackTrace);
}
}

"~toki" <pedorro77.hotmail.com> escribió en el mensaje news:Ow**************@TK2MSFTNGP11.phx.gbl...
Thanks, it don't work (yet) but i understand where start.
Something like this..
System.Diagnostics.Process p = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo();
info.UseShellExecute = false;
info.CreateNoWindow = false;
info.FileName = app;
info.RedirectStandardOutput = true;
p.StartInfo = info;
p.Start();
p.WaitForExit();
Console.WriteLine( p.StandardOutput.ReadToEnd() );
I will investigate it...

"Michael A. Covington" <lo**@www.covingtoninnovations.com.for.address> escribió en el mensaje news:%2****************@TK2MSFTNGP09.phx.gbl...
Ah! Creo que lo que Ud. intenta es que quiere comunicar con otro proceso
por "standard input" y "standard output". No se' como se hace.

Anyone -- How do you get a process to read and write to another process's
stdin and stdout? If you can?


"~toki" <pedorro77.hotmail.com> wrote in message
news:uo**************@TK2MSFTNGP11.phx.gbl...
I have the server source in C# and the client is an .exe (made in C)
I see how talk with a "debug windows" of the client.
The client send two tokens to the server.
And the server response with a token (that exists in the source code) with
Console.Write(returnToken);
It works fine.
I can't run the C# server from the MS IDE to stop and debug when the

client
send the token.

*The client run the server when it start.

I have tried do it with System.Diagnostic.Process.Start("server.exe") but

it
don't work.
"Michael A. Covington" <lo**@www.covingtoninnovations.com.for.address>
escribió en el mensaje news:ei**************@tk2msftngp13.phx.gbl...

"~toki" <pedorro77.hotmail.com> wrote in message
news:ed**************@TK2MSFTNGP10.phx.gbl...
> I have a full work app (server and client) that talk between two
executables
> trought Console.WriteLine(); & Console.ReadLine();
...
> But never can read anything.
>
> I know good how to make a client server with TCP. But with Console

appears
> to be different.
> When is "established" the connection?

As far as I know, different applications cannot communicate through a
console. Do you have some information indicating that they can?



Nov 16 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: jason | last post by:
I have a function that <body onload=..> sets some form values. However when i execute that functionf from external js file, i get erorrs and it dont work. The function sets the fields via ...
7
by: ~toki | last post by:
I have a full work app (server and client) that talk between two executables trought Console.WriteLine(); & Console.ReadLine(); I have the source code of the server. I need to make the client....
3
by: Gustavo L. Fabro | last post by:
Greetings! I'm a newbie in Visual C++ .NET (have programmed in Borland C++ and Builder for long) and I am trying to do a very simple thing, but I'm stuck. I created an (unmanaged) DLL project...
2
by: jpeters | last post by:
Just installed Service Pack 5 for Visual C++ 6.0. Now I'm getting an error when linking as follows: inking... LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16...
0
by: Steve Caine | last post by:
Hello, I'm new to the .NET world and trying to learn from the sample code in Visual Studio 2003's C++ environment. When I try to compile their "MECalculator" sample (which demonstrates...
2
by: Lonifasiko | last post by:
Hi group, I must launch from my Winforms application another application (.exe developed by the client) which response time sometimes can be more or less 30 seconds. I'm using ProcessManager...
3
by: lookaround | last post by:
Hi everyone, I need some help... I call an external exe (a command-line tool) with Process.Start through this code: try { p = new Process(); p.StartInfo.UseShellExecute = false;...
1
by: =?Utf-8?B?Q3JhaWc=?= | last post by:
Hi Guys, I am trying to caputre the output for an external application. The idea is to use the System.Diagnostics.Process to run the exe in a process and redirect the output to a string. When...
5
by: goje | last post by:
Hello I want to capture the Output of the External Console Application in my application and also want to send commands to External Console Application from my application. Someone have some...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.