/AsynchronousClient

Asynchronous Client Socket Example according to the Task-based Asynchronous Pattern. (C#)

Primary LanguageC#

Asynchronous Client Socket Example

The following example program creates a client that connects to a server. The client is built with an asynchronous socket, so execution of the client application is not suspended while the server returns a response. The application sends a string to the server and then displays the string returned by the server on the console.

Reference

This source is based on the Microsoft site example. Microsoft example is written based on the old IAsyncResult pattern. But this source is rewritten according to the Task-based Asynchronous Pattern. (TAP)

Two Template

I use two template source for rewrite old pattern to Task-based Asynchronous Pattern.

Template1: use Begin* and End* methods to change Pattern.

Template2: use base socket methods to change Pattern. (like Send, Receive, and so on)

See Also

Microsoft Example

Task-based Asynchronous Pattern

Interop with Other Asynchronous Patterns and Types