Sockets Vs. WCF

I work in a chat application where I use Silverlight on the client side and wpf on the server side. Right now, communication is based on Sockets: I have different classes of messages that I serialize and send over TCP.

I am starting to understand that creating a separate message class for each possible communication scenario is quite an overhead and consider switching to WCF.

Therefore, I need to know the following things:

  • It seems that all the communication using WCF is based on user-tested calling methods from my WCF service. Is there a way to find out which client is invoking a particular method? This is very important for my application.

  • Does WCF tell my application when a client disconnects (for example, closes the browser window where the Silverlight client is running) from the server? This is also very important.

  • Is the method completely asynchronous? If so, is it necessary to redirect the call of each method to the main thread of the server application?

  • Does each client connection have its own thread? How many simultaneous connections could be made by a server (running on a computer with moderate power) if the clients called the conversation methods every 2 seconds? I just need a grade (10, 100, 1000 or more). "More" would be great;)

Perhaps I am completely wrong, and WCF does not work at all based on the connection. Then I will have to find a temporary solution to manage the list of active connections.

Thank you for your help! Andrey

+6
sockets wcf
source share
3 answers
  • Since you use the Silverlight application, you can embed a UserNamePassword Validator at the message level, which adds some headers to the soap message, this can be used to uniquely identify clients, unless the clients are anonymous. then you can use System.ServiceModel.OperationContext.Current when you need to access the username elsewhere in the wcf service.

  • The server is not notified when the client disconnects, since msgs are "PerCall" by default, there is a way to use the Singleton class as ur ServiceContract with InstanceContextMode.Single, and then implement OperationContract with the callback service, then when clients enter the ur service, they must register with the callback service, the ur callback service can then go through connected clients and check the status of the callback, whether it remains open or not, finally delete records in which connections are closed, eventually toga you can get the necessary functionality.

  • Asynchronous calls from the client, i.e. in Silverlight all webservice calls are asynchronous, like in ASP, you have a choice, WCF automatically processes the asynchronization function, so you don’t need to redirect anything, just encode ServiceContract as a separate thread, and everything will be fine

  • Implement binary encoding of messages in silverlight 3 in order to get the most out of the ur server and its bandwidth, silverlight does not support raw tcp connections, it must be deleted in the http message for very good reasons. Each client can have many simultaneous calls (asynchronous storage), so to keep things simple, just think about it, as if the server has a separate thread for each message call. Therefore, to answer your question about what you just said, 1000.

+4
source share

For 3, I know you can call async.

And for 4, yes, they have their own flows. WCF is pretty BIG and complicated, you have to get a book to understand it better.

0
source share

My answers:

  • Yes. All communications are based on calling methods.
  • In general, no.
  • You can call methods synchronously or asynchronously. This is your choice.
  • Additionally. I am doing the right system design.
0
source share

All Articles