C # Difference between BeginAccept and AcceptAsync

5

What is the difference between the two asynchronous forms? Which has better performance by handling sockets and handling thousands of connections simultaneously?

Example for BeginXXX: link

Example for XXXAsync: link

    
asked by anonymous 12.06.2014 / 00:59

2 answers

1

None. One was made to meet a "standard" asynchronous programming and the other one.

See: link

The first "Begin" is to meet the Asyncronous Programming Model (APM) and the second (BlahBlahBlahAsync) to meet the Task-based asyncronous pattern (TAP). Tasks' is newer and simpler to use.

In time, on my blog: link you find examples of socket server with both scenarios and some explanations about the gains obtained with I / O asynchronous in general.

    
14.07.2014 / 19:59
0

In terms of performance, both are the same, the connection is always made using the "Socket" class.

But in the BeginXXX example, it is a simpler solution, using the basic form of Async usage.

In the example of XXXAsync is an example based on events, this example is more complete because in this example it already expects up to 100 concurrent connections as can be seen in this line:

listenSocket.Listen(100);

To describe what you need, you could use any of these solutions, but XXXAsync is already closer and ready for what you want, notice that it is already an example of a server, just implement the desired actions .

Now, depending on what you do, and who you consume, you can eliminate various network layer concerns by using WCF or even WebAPI. But that will depend on the requirements of the project.

    
03.07.2014 / 15:07