O'Reilly logo

Microsoft® Visual J#™ .NET (Core Reference) by John/Longshaw, Andy Sharp

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using Sockets Asynchronously

You should use the connection-oriented TCP protocol if you’re building synchronous clients and servers and you want to ensure that data is transmitted successfully between them. TCP comes at a price, though—sometimes you’ll simply want to use the datagram approach of UDP because of its inherently asynchronous nature, despite the lack of guarantees. Let’s look at some of the features of sockets under .NET that you can use to build reliable, asynchronous applications and get the best of both worlds.

The Poll and Select Methods

The TCP examples shown earlier created a thread for each client that connected to the server. Threads consume resources, and lots of threads consume lots of resources. Do you know how many concurrent ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required