问题
I want to create a simple chat application that doesn't use an explicit server. The main requirement is that the user can simultaneously chat with many friends (just like on Skype etc.). I do not mean a conference chat here, just multiple separate chat-windows.
Currently, I want only a LAN messaging application but I'd appreciate, if the design was easy to extend to Internet connections.
I wonder what design is appropriate for such an application.
- What do you think about a solution, where each user app has a
TcpListener
(the implicit server) and multipleTcpClient
objects - one for each friend he/she is talking to. - What about authenticating the remote users? Should the chatting app generate a certificate (X509 or sth) or just assume that the users in a LAN are to be trusted :)
Kindest regards,
回答1:
HttpListener
+ WebClient(or HttpWebRequest)
can provide you more tools for authentication/security.
Basic Authentication, Ntlm, Integrated Windows Authentication, https etc. and they are more firewall friendly.
回答2:
You should see start with
how do i make my own P2P software?
WCF / WPF Chat Application
P2P Communication - Proxy Listeners and Proxy Clients
Hope this proves good starting point
Happy coding
来源:https://stackoverflow.com/questions/8683663/c-sharp-p2p-chat-application-design