tags:

views:

679

answers:

4

Hi everyone,

I want to make a P2P Chat client, all I want it to do is to be able to send text across to each peer.

I looked at a Chat Client from this example: http://www.geekpedia.com/tutorial239_Csharp-Chat-Part-1---Building-the-Chat-Client.html

And am wondering if it can be converted to a p2p program? If so how can it be and can someone provide some code as it will help a lot.

If it can't how can I make a really simple p2p chat program? Codes and examples will be very helpful.

btw I did look at this article, but it didn't help me: http://msdn.microsoft.com/en-us/library/ms751502.aspx

A: 

For P2P, you need to use UdpClient instead of TcpClient. Google should help you from here :)

Edit: Sorry, I made false assumptions in this answer. If you want to continue using TCP, that's just fine. Instead of creating a separate server application, add the server code to your client application, so that either the sender or receiver acts as the server.

brydgesk
The is no reason you need to use UDP for a P2P app.
TJMonk15
Why is UDP better in this case? Can you post some references?
IVlad
You can use both TCP and UDP according to your scenario. If its data transfer that cannot tolerate loss of data then TCP is more suitable. If you're streaming audio or video and can tolerate some amount of data loss then you can use UDP as it does not guarantee reliable data transfer and for this reason it is more fast.
jaxvy
Sorry, I was just wrong. I always think of P2P in terms of being connectionless, but you're right, there's no reason it has to be that way.
brydgesk
So I can keep my TCP Connection? I also thought of it as being connectionless in some ways, since it doesn't really use a server.
Sandeep Bansal
UDP is usually better for peer-to-peer since it can (sometimes) traverse NAT, which is not possible with TCP. Also check out code.google.com/p/lidgren-network (shameless plug) - it contains a peer-to-peer chat sample.
lidgren
Thanks, I guess this question has got some info I could look into.
Sandeep Bansal
A: 

I did a similar project once, only using bluetooth rather than Internet.
Mine wasn't chat so much as IM, since it only allowed for two people to converse, but we got it working by using the technique in brydgesk's edit and having the client ('talker') and server ('listener') together in the same application, in such a way that the server only puts out received messages to the local client, rather than rebroadcasting to all connections.

Hope this little bit is helpful, I don't think this is really the right place to help you write the entire application.

Zind
Thanks it did help me to understand, I wasn't really requesting a whole chunk of code to be written here, just a snippet of what I can do.
Sandeep Bansal
A: 

If it is to be done on the intranet, why not use WCF named pipes? I provide an example on my blog entitled: Create a Intra-Application Named Pipe using WCF in .Net using C#; IPC Communications.. You will need to use the non local http bindings so its not local to the machine. HTH

OmegaMan
A: 

Try http://code.google.com/p/jabber-net/

Brownman98