Ido Sorozon
Ido Sorozon

Reputation: 83

Creating p2p chat with Tcp protocol in c#

I made a p2p chat using tcp protocol where each user runs a server(have a TcpListner listening). Is that a problem?

-----Edit

I need to add that the listener is on one thread and the client on another

Upvotes: 1

Views: 2818

Answers (2)

Navin
Navin

Reputation: 534

Well running listener on another thread and writing on another thread is fine, or you can use async listener. Well the actual problem is unless you have used TCP hole punching technique the chat application wont work outside your LAN. I hope you know what you doing. Just for more information i can add up some facts here. If you are planning to use the application outside your LAN then you need to communicate through you public IP. if your public IP is not static then your request will be blocked by the NAT. In order to overcome this issue you need to break the NAT using TCP/UDP hole punching . Just search on google you will get more a lot of tutorial on this. Let me know if none of them didn't work out for you.

Upvotes: 0

user2608161
user2608161

Reputation:

No, it is not a problem. Each client needs the ability to act as both a server and a client in a P2P program, so you went the right way.

EDIT: Yes, it is alright that the listener and client are on separate threads.

EDIT2: This question and its answers may be worth reading.

Upvotes: 1

Related Questions