tags:

views:

216

answers:

4

I would like to write a c# server that will act roughly as a chat server ( clients are connected for a while, same message could be dispatched to many clients , .... ).

I was wondering if you can give me some hints to start (what kind of architecture ( threads by clients / iocp / asynchronous / ...) that will allow to scale well ( should be able to handle thousands of simultaneous connections ) ).

+2  A: 

Here is a tutorial that will get you off to a good start.

Looks like it uses a threaded implementation so it should scale well.

Building a Chat Server and a Chat Client

KClough
A: 

This might be a good place to start: http://www.dreamincode.net/forums/showtopic33396.htm

Irwin
+2  A: 

Here is an example using WCF: http://www.codeproject.com/KB/WCF/WCFWPFChat.aspx

Hopefully you would not have to deal with raw sockets by using WCF, it would be interesting to see if WCF could handle the thousands of connections though...

John JJ Curtis
Is this a genuine concern? If WCF can't scale, what is a suitable replacement?
Jason
+1  A: 

If you need scalability of the kind you are talking about, IOCP is the only way to go.

There are some pitfalls to be avoided though, so read my detailed answer on: http://stackoverflow.com/questions/869744/how-to-write-a-scalable-tcp-ip-based-server/908766#908766 in conjunction with the accepted answer on the same question.

jerryjvl