开发者

What's the best way to build a C# .NET client-server chat application? [duplicate]

开发者 https://www.devze.com 2023-04-09 04:52 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: multi client/server chat program in c#?
This question already has answers here: Closed 11 years ago.

Possible Duplicate:

multi client/server chat program in c#?

I've been trying for some time to build a simple client-server chat, and I keep finding that there are a number of different ways.

I was just curious as to what the most correct way would be.

The first involves creating a new socket, binding it to a specific port and any IP Address, then listening for new connections (and that's as far as the tutorial leads). The next involves using a TcpListener to listen on a specific port (though it issues a warning saying that its deprecated, and I must include an IP address), it then waits for a new TCP connect开发者_如何学JAVAion, then creates either a new hashtable or new list to store the TcpClient(s). And that's all server side. Client side its pretty much the same, always trying to connect to the server.

So, what's the best way to go about building one? Also, should I use StreamReader and StreamWriter (which some tuts use), or should I use NetworkStream, what should I use to transfer the messages?


You are on the right track. However you might want to look into some of the more advanced features of WCF, such as Duplex services that will allow a push from the server based on an event.


Personally, I would just setup a XMPP server and talk it with Jabber.net (http://code.google.com/p/jabber-net/) or something else but I haven't looked in a few years.

0

精彩评论

暂无评论...
验证码 换一张
取 消