0

I would like to have a client-server application written in .NET which would do following:

  • server is running Linux
  • on the server there is SQL database (mySQL) containing document URLs

What we want: - server side would regularly crawl all URLs and create a full text index for them - client side would be able to perform a query into this index using GUI

The client application is written in .NET using C#. Besides of searching in documents it will be able to do a lot of other things which are not described here and which are done client-side very well.

We would like to use C# for the server side as well, but we have no experience in this area. How are things like this usually done?


Clarifying question now based on some answers:

The thing which is most unclear to me is how client-server communication is usually handled. Is client and server usually using sockets, caring about details like IP addresses, ports or NAT traversal? Or are there some common frameworks and patters, which would make this transparent, and make client-server messaging or procedure calling easy? Any examples or good starting points for this? Are there some common techniques how to handle the fact a single server is required to server multiple clients at the same time?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Suma
  • 33,181
  • 16
  • 123
  • 191
  • You would need to use Mono if you want linux server-side. – UpTheCreek Jan 26 '10 at 10:00
  • Of course, there's nothing to stop you having the Client Side .Net app communicate with a non-.Net server implementation. – UpTheCreek Jan 26 '10 at 10:02
  • 1
    .NET isn't the obvious choice for Linux server. Yes, there is Mono, but it's not guaranteed to be 100% compliant. There is no reason why the server can't be in (say) Java and the Client in C#, so long as they talk to each other. – Dan Diplo Jan 26 '10 at 11:01
  • What sort of application are you developing? this will have a big impact on the decisions you should make. Games require lots of low latency bi-directional communication. Busines/DB CRUD applications talk infrequently initiated by client, can have multisecond lag times. If you give us a bit more detail we can be more specific in our advice. – David Waters Jan 26 '10 at 12:50
  • 1
    Java+C#: look into web services. Basically, you (typically) send HTTP requests to a server, and it sends you back XML. Kind of like using a browser to make a remote procedure call. – TMN Jan 26 '10 at 13:33
  • No, it is not game this time. I have a lot of experience with multiplayer games, which we do using UDP sockets and similar low level constructs. This is a content management tool - namely its indexing and searching part. For this I would prefer something which would be a lot higher level. Web Services seem good so far, TCP .NET objects might do the job as well. – Suma Jan 26 '10 at 19:14

5 Answers5

1

To use c# on Linux you will need to use Mono. This is an open source implementation of the CLR specification.

Next you need to decide on how to communicate between server and client, from the lowest level of just opening a TCP/IP socket and sending bits up and down, to .Net remoting, to WCF, to exposing webservices on the server. I do not know how compleat WCF implementation is on mono, also I think you may have issue with binary remoting between mono and MS .Net .

I would suggest RPC style WebServices offer a very good solution. WebServices also have the advantage of alowing clients from other platforms to connect easily.

EDIT In response to the clarification of the question. I would suggest using mono/ASP.NET/WebServices on the server, if you wish to use c# on both server and client.

One assumption I have made is that you can do a client pull model, where every message is initiated by the client. Using another approach could allow the server to push events to the client. Given the client has the ability to pole the server regularly I don't consider this much of a draw back but it may be depending on the type of application you are developing.

Mono allow execution of c# (compiled to IL) on a Linux box. Mono ASP.NET allows you to use the standard ASP.NET and integrate into Apache see http://www.mono-project.com/ASP.NET and finally WebServices allow you to communicate robustly in a strongly typed manner between you client and your server.

Using this approach negates most of the issues raised in your clarification and makes them someone else's problem.
Sockets/SSL - is taken care of by standard .Net runtime on the client and Apache on the server.
IPAddress/ports/NAT traversal - Is all taken care of. DNS look up will get the servers IP. Open socket will allow the server to respond through any firewall and NAT setup.
Multiple Clients - Apache is built to handle multiple clients processing at the same time as is ASP.NET, so you should not encounter any problems there.

Suma
  • 33,181
  • 16
  • 123
  • 191
David Waters
  • 11,979
  • 7
  • 41
  • 76
  • following up on a comment on the question. I too would advise using a more matuer and supported environment on the server, like Java. C# and Java can talk easily between each other using either Raw sockets/http/webserverices. – David Waters Jan 26 '10 at 12:52
1

As many have already mentioned there are a number of thing that you have mentioned which are going to cause you pain. I'm not going to go into those, instead I will answer your original question about communication.

The current popular choice in this kind of communication is web services. These allow you to make remote calls using the HTTP protocol, and encoding the requests and responses in XML. While this method has its critics I have found it incredibly simple to get up and running, and works fine for nearly all applications.

The .NET framework has built in support for web services which can definitely be called by your client. A brief look at the mono website indicates that it has support for web services also, so writing your server in C# and running it under mono should be fine. Googling for "C# Web Service Tutorial" shows many sites which have information about how to get started, here is a random pick from those results:

http://www.codeguru.com/Csharp/Csharp/cs_webservices/tutorials/article.php/c5477

Jack Ryan
  • 8,396
  • 4
  • 37
  • 76
0

have a look at Grasshopper: "With Grasshopper, you can use your favorite development environment from Microsoft® to deploy applications on Java-enabled platforms such as Linux"

Or see here

The ideea is to convert your app to Java and then run it on Tomcat or JBoss.

lmsasu
  • 7,459
  • 18
  • 79
  • 113
0

Another approach: use the Mod_AspDotNet module for Apache, as described here.

lmsasu
  • 7,459
  • 18
  • 79
  • 113
  • I am afraid ASP.NET is not what I am for, if I undestand correctly what ASP.NET. I would like to have a real client side standalone application, not a web based UI. – Suma Jan 26 '10 at 10:23
0

This Basic Client/Server Chat Application in C# looks like a kind of example which might be a starting point for me. Relevant .NET classes are TcpClient and TcpListener

Suma
  • 33,181
  • 16
  • 123
  • 191