Communicate UNIX from c#

  • Thread starter Thread starter Bala Nagarajan
  • Start date Start date
B

Bala Nagarajan

Hi,

How do i communicate between C# and Unix? The scenario is as follows.

I have a C program residing in UNIX box that does complex calculations and
returns a result. I need to invoke this C program residing in the Unix
box from Windows Client C# application through a button click event. How do
i
manage to call a C program residing in Unix box from C# and get the
result back?

It would be really helpful if you expalin me a way to acheive this.


Thanks

-Bala
 
This sounds like an ideal Web-Service scenario.

I have seen situations where WinForms clients used a java webservice on a
Linux box for processing tasks. Perhaps you should investigate that avenue
of approach.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
That's a 2 step problem.
1st your unix program work in 'server mode', that is be able to listen to
incoming connection and answer them somehow.
2nd your client should talk to this server.

Now if you maintain both product and that the C program has no server mode,
you should develop one.
As Bob suggested develop it as a WebServicde server sounds like an
appropriate idea.
 
Bala said:
How do i communicate between C# and Unix? The scenario is as follows.

I have a C program residing in UNIX box that does complex calculations and
returns a result. I need to invoke this C program residing in the Unix
box from Windows Client C# application through a button click event. How
do i
manage to call a C program residing in Unix box from C# and get the
result back?

It would be really helpful if you expalin me a way to acheive this.

I gave you an elaborate reply when you first posted this very same
question in the Remoting newsgroup. Have you seen that?


Oliver Sturm
 
Thanks everyone for your response. Actually i will not be able to implement
a web service in the UNIX box due to some constraints. Leaving the Web
service do i have any other option?

Thanks a lot for your help.


-Bala
 
Sockets? Write a simple server for the unix box and hit it with a socket
connection.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
Thanks a lot. Sockets just work fine.
Another question. My server program in the Unix box accepts only a C struct
type. How do i pass a struct from C# client application that is compatible
with the server C program?How do i modify my client c# application without
changing anything in the server?

Thanks

_bala
 
Another question. My server program in the Unix box accepts only a C
struct type. How do i pass a struct from C# client application that is
compatible
with the server C program?How do i modify my client c# application without
changing anything in the server?
there is no such thing as a 'default way to write a C struct in a file'(the
socket in this case).
I advise you to check which format expect the C server and write the same
thing in C#.

BTW web services are just for that.
every time you want to call a new method or pass a new parameter, you've got
plenty of tedious coding to write.
Web service are real easy to write in C#.
In C it would still be a tedious task but, at least, you will find plenty of
library which makes it 'relatively easy' as far as C program are
concerned...
 
Thanks for the reply. I will not be able to write a Web Service on the
server due to some constraints though it is an excellent idea.
Another question: Is there a way to FTP a file to a Unix box and get a file
back from C# application?

Thanks

-Bala
 
How do i logon to a Unix box and invoke an executable in that box through
c#?


Thanks

-Bala
 
Hi Bala,

To use C# on Unix, we must have .Net Framework installed. Currently, the
Unix version of .Net is Mono, we may install mono to run C#. With Mono, I
think we can use Process.Start to run an executable.

Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hi Bala,

FTP is a standard protocol, which is independent of the OS platform. So we
can first install a FTP server ware on the Unix machine, then on client
machine, we can use C# socket classes to write a FTP client to communicate
with the server ware. There are a lot of articles about how to write a FTP
client in .Net, please refer to:
"FTP Explorer in C# (Beta 2)"
http://www.c-sharpcorner.com/winforms/NFTPExplorer_Beta2.asp
"Write an FTP Client with VB.NET to Bridge Legacy Software"
http://www.codeguru.com/vb/vb_internet/html/article.php/c8459/

Hope this helps

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hi Bala,

Does my reply make sense to you? Is your problem resolved? Please feel free
to tell me, thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hi Jeffrey,
Thanks a lot for the response. I have not tried it yet but your
idea has pointed me in the right direction.
Thanks for the support.

Bala
 
I am glad my reply can help you. If you need further help, please feel free
to post. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top