all groups > dotnet windows forms > september 2005 >
You're in the

dotnet windows forms

group:

Communicate UNIX from c#


Communicate UNIX from c# Bala Nagarajan
9/29/2005 6:13:27 PM
dotnet windows forms: 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

Re: Communicate UNIX from c# Bob Powell [MVP]
9/30/2005 1:26:27 AM
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.





[quoted text, click to view]

Re: Communicate UNIX from c# Oliver Sturm
9/30/2005 10:22:50 AM
[quoted text, click to view]

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


Oliver Sturm
--
Expert programming and consulting services available
Re: Communicate UNIX from c# Bala Nagarajan
9/30/2005 10:24:32 AM
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


[quoted text, click to view]

Re: Communicate UNIX from c# Lloyd Dupont
9/30/2005 10:25:53 AM
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.

--
If you're in a war, instead of throwing a hand grenade at the enemy, throw
one of those small pumpkins. Maybe it'll make everyone think how stupid war
is, and while they are thinking, you can throw a real grenade at them.
Jack Handey.
[quoted text, click to view]

Re: Communicate UNIX from c# Bob Powell [MVP]
9/30/2005 6:36:19 PM
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.





[quoted text, click to view]

Re: Communicate UNIX from c# Bala Nagarajan
10/4/2005 4:21:28 PM
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

[quoted text, click to view]

Re: Communicate UNIX from c# Lloyd Dupont
10/5/2005 12:00:00 AM
[quoted text, click to view]
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...

Re: Communicate UNIX from c# v-jetan NO[at]SPAM online.microsoft.com (
10/5/2005 12:00:00 AM
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.
Re: Communicate UNIX from c# v-jetan NO[at]SPAM online.microsoft.com (
10/5/2005 12:00:00 AM
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.
Re: Communicate UNIX from c# Bala Nagarajan
10/5/2005 10:50:22 AM
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

[quoted text, click to view]

Re: Communicate UNIX from c# Bala Nagarajan
10/5/2005 1:57:12 PM
How do i logon to a Unix box and invoke an executable in that box through
c#?


Thanks

-Bala






[quoted text, click to view]

Re: Communicate UNIX from c# v-jetan NO[at]SPAM online.microsoft.com (
10/13/2005 7:38:36 AM
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.
Re: Communicate UNIX from c# Bala Nagarajan
10/17/2005 11:19:02 AM
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

[quoted text, click to view]

Re: Communicate UNIX from c# v-jetan NO[at]SPAM online.microsoft.com (
10/18/2005 12:00:00 AM
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.
AddThis Social Bookmark Button