TCP or UDP help with a server/client in c#?

It fully supports messaging over TCP/IP, using binary data transfer, but it's at a much higher level of abstraction than raw sockets.

Yep! God your right! I have been using wcf for my web services ... One thing though does it allow the server to PUSH information to the client?

Basically that client needs to receive msgs but it should need to POLL? .. if this is the case I think this solved my issues – mark smith Jul 4 '09 at 14:01 and I presume its going to work behind NAT? – mark smith Jul 4 '09 at 14:04 @mark: I don't know about pure push scenarios, though I know it supports duplex channels, which provide for a callback from the service to the clients.As to NAT, see msdn.microsoft.

Com/en-us/azure/dd441706. Aspx and realize they did all that just by using extensibility points you can use as well, whether you use their code to do it or not. – John Saunders Jul 4 '09 at 14:12 Thanks!

I have gone with this answer as it seems WCF suits my needs! But thank you everyone else for comments with regards to TCP and UDP – mark smith Jul 4 '09 at 15:36 I think that wcf callback channels are actually two separate unidirectional connections, so nats and firewalls are going to be a problem. Using tcp sockets will provide you with real full duplex messaging after initial setup.

Check out System.Net. Socket and System.IO, all you need is there. – Pablote Jul 4 '09 at 16:03.

It sounds to me like you're not clear on the distinction between TCP and UDP. TCP is connection oriented. I.e.2 peers will have a dedicated connection.

Packet delivery and ordering is guaranteed. Typically a server will present a port, and multiple clients can connect to that port (think of a HTTP server and browsers). UDP is connectionless.It doesn't guarantee packet delivery, nor ordering.

You can implement broadcast and multicast mechanisms very easily. If you need some sort of reliability, you will have to implement this on top of UDP. Sometimes you may not care, and simply issue requests and retry on no response (SNMP does this).

Because it's connectionless, you don't really worry about peers being up/down. You just have to retry if required.So your choice of protocol is dictated by the above. E.g.

Does your client require a dedicated connection to the server? Are you transmitting the same data to multiple clients? Can you tolerate packet loss (e.g. Real time price updates etc.).

Perhaps it's feasible to use both TCP and UDP for different requirements within your app (e.g. TCP for registering orders, UDP for transmitting price updates/events?) I'd consider your requirements, and familiarise yourself with the limitations and features of TCP and UDP. That should make things a little clearer.

Everything you need is in . Net 3.5 (and probably below). Check out the documentation and examples with the UdpClient class at MSDN for insight into how to write your client/server.

A quick google found some sample code for a server and client at java2s.com among many other networking examples in C#. Don't be put off by the domain name.

UDP cons: packet size restriction means you can only send small messages (less than about 1.5k bytes). Lack of stream makes it hard to secure UDP: hard to do an authentication scheme that works on lossy exchange, and just as hard to protect the integrity and confidentiality of individual messages (no key state to rely on). No delivery guarantee means your target must be prepared to deal with message loss.

Now is easy to argue that if the target can handle a total loss of messages (which is possible) then why bother to send them in the first place? UDP Pros: No need to store a system endpoint on the server for each client (ie. No socket).

This is one major reason why MMO games connected to hundred of thousands of clients use UDP. Speed: The fact that each message is routed individually means that you cannot hit a stream congestion like TCP can. Broadcast: UDP can broadcast to all listeners on a network segment.

You shouldn't even consider UDP if you're considering TCP too. If you're considering TCP means you are thinking in terms of a stream (exactly once in order messages) and using UDP will put the burden of fragmentation, retry and acknowledgment, duplicate detection and ordering in your app. You'll be in no time reinventing TCP in your application and it took all engineers in the word 20 years to get that right (or at least as right as it is in IPv4).

If you're unfamiliar with these topics I recommend you go with the flow and use WCF, at least it gives you the advantage of switching in and out with relative ease various transports and protocols. Will be much harder to change your code base from TCP to UDP and vice versa if you made the wrong choice using raw . Net socket components.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions