Client Server Communication  
Author Message
sroughley





PostPosted: .NET Framework Networking and Communication, Client Server Communication Top

Hey all,

I am investigating a system that will be comprised of two components: a Windows Forms application that will be installed on client machines, a Windows Service application that will be installed on a Windows server. The client will need to poll the service across a standard Windows network to check to see if the service has any data to send. If there is data available, the service must send it to the client so that the client can use it. The question is how do I implement this functionality

I am wanting to keep the system complexity low and it needs to be fast. I was thinking about using TCP/IP sockets, but have little knowledge about this so any advice you guys have to offer would be great!

Thanks in advance,

Stephen.



.NET Development35  
 
 
V.Tortola





PostPosted: .NET Framework Networking and Communication, Client Server Communication Top

I wrote something like this.

I use MSMQ to do it. Serialize structs in operating system queues in the server, and clients connect to her respective queues and a global queue to get the messages (messages that contains structs or objects)

http://msdn.microsoft.com/library/default.asp url=/library/en-us/vbcon/html/vbconintroductiontomessaginginvisualstudio.asp

Regards.


 
 
sroughley





PostPosted: .NET Framework Networking and Communication, Client Server Communication Top

Nice one! I'll look into that.
 
 
RizwanSharp





PostPosted: .NET Framework Networking and Communication, Client Server Communication Top

You can use TcpListener, TcpClient and NetworkStream classes and can build a very simple and robust solution as computer to using Serialization or Remoting.

See Samples and descryption of all these classes here:

http://msdn2.microsoft.com/en-us/library/system.net.sockets.tcpclient.aspx

http://msdn2.microsoft.com/en-us/library/system.net.sockets.tcplistener.aspx

http://msdn2.microsoft.com/en-us/library/system.net.sockets.networkstream.aspx

If you need more help! feel free to write again ;-)

Best Regards,



 
 
sroughley





PostPosted: .NET Framework Networking and Communication, Client Server Communication Top

Just what I was after! I'll investigate and let you know how I get on.

Also been looking into MessageQueuing and it looks quite useful. I especially like the transactional behaviour and its ease of implementation.

Thanks for the help guys!

Regards,

Stephen.

 
 
V.Tortola





PostPosted: .NET Framework Networking and Communication, Client Server Communication Top

Mark the replies like answers to better forums search engine performance

I'm glad with you like MSMQ, is very easy and very usefull, the only thing is you must add the [Serializable] attribute at the class/struct that you want use like message ;)

Regards.


 
 
sroughley





PostPosted: .NET Framework Networking and Communication, Client Server Communication Top

OK. It looks like we'll probably be going with TCP client/server communication as it will better fit our application. The question I have now is more of an architectural issue. The app is going to be designed using n-tier architecture and I would like a bit of advice regarding how to distribute the application logic.

Most of the data processing and persistence is going to be handled on the server, while the clients are going to act primarily for viewing data. So I am thinking it would be best to have the core DAL reside entirely on the server and simply have a client level data access component that sends and receives data to and from the server via TCP.

Any ideas

Regards,

Stephen.


 
 
RizwanSharp





PostPosted: .NET Framework Networking and Communication, Client Server Communication Top

Your Approcah is absolutely Fine! I developed something like:

Client Class // Used on Client end to deal with Connection and all Communication with Remote Machine

Client Proxy Class // Used on the Server end to deal communication with the connected client

Both Classes are self tuned and self run The initiaters only create and object and call Connect functions. That's It.

Use Asynchronous sockets (Non blocking) Avoid MultiThreading.

What Else Hmm! Think and share with us, So we can learn more with better Ideas you have :)

Best Regards



 
 
sroughley





PostPosted: .NET Framework Networking and Communication, Client Server Communication Top

Thanks for the response.

When you implemented your system, did you have to deal with transactions accross the client/server connection If so, how did you achieve this Also, when sending and receiving data, how did you identify what was being sent and received That is, what did you send to the server to either request specific data, or to let the server know you were sending data that needed to be persisted

Thanks again,

Stephen.


 
 
RizwanSharp





PostPosted: .NET Framework Networking and Communication, Client Server Communication Top

I did not deal with Database or stuff, What I did was a simple Chat, File Sharing system with Encryption. I developed my own Packet format to do this.

If you are doing something with Database then you can use XML to send complete data objects. Use Serialization!

I hope this will help.

Best Regards,



 
 
sroughley





PostPosted: .NET Framework Networking and Communication, Client Server Communication Top

Right-oh.

We are already looking at using DataSets and wrapping them in a Serlializable class. The type would then determine the communication action so that we would have a PersistRequest type, containing a DataSet to be persisted, and DataRequest type, containing a data request command. I am also now thinking that this could be a good idea for handling transactions as the PersistRequest class, for example, could have a transactionId property to identify a transaction across multiple requests.

This is all currently theoretical for us though, so I'd still love to hear what you all think!

Regards,

Stephen.