Questions tagged [socketasynceventargs]

The SocketAsyncEventArgs class of the .Net framework is part of a set of enhancements to the System.Net.Sockets.Socket class that provide an alternative asynchronous pattern that can be used by specialized high-performance socket applications.

The SocketAsyncEventArgs class of is part of a set of enhancements to the System.Net.Sockets.Socket class that provide an alternative asynchronous pattern that can be used by specialized high-performance socket applications.

The main feature of these enhancements is the avoidance of the repeated allocation and synchronization of objects during high-volume asynchronous socket I/O.

54 questions
11
votes
1 answer

20 Receives per second with SocketAsyncEventArgs

A TCP Server is developed using SocketAsyncEventArgs and it's async methods as a Windows Service. I have these 2 line of code at the beginning of Main: ThreadPool.SetMaxThreads(15000, 30000); ThreadPool.SetMinThreads(10000, 20000); And both return…
Kaveh Shahbazian
  • 13,088
  • 13
  • 80
  • 139
9
votes
1 answer

C# SocketAsyncEventArgs handling receive and send data

I am trying to understand the 'SocketAsyncEventArgs' class in C#. http://msdn.microsoft.com/en-us/library/system.net.sockets.socketasynceventargs.aspx I am following this…
user1149696
7
votes
1 answer

How use BufferList with SocketAsyncEventArgs and not get SocketError InvalidArgument?

I can use SetBuffer with SocketAsyncEventArgs just fine. If I try to use BufferList (after doing SetBuffer(null, 0, 0)) I always and immediately get SocketError InvalidArgument (10022) when I do SendAsync on the socket. There are NO examples or…
Dave
  • 1,822
  • 2
  • 27
  • 36
5
votes
2 answers

.NET Async Sockets: any benefit of SocketAsyncEventArgs over Begin/End in this scenario?

Socket has these new async methods since .NET 3.5 for use with SocketAsyncEventArgs (e.g. Socket.SendAsync()), benefits being under the hood they use IO completion ports and avoid the need to keep allocating. We have made a class called UdpStream…
Jack Ukleja
  • 13,061
  • 11
  • 72
  • 113
5
votes
1 answer

How to implement IDisposable interface in a class inherited from SocketAsyncEventArgs

I work on a huge project in C# .NET 4.0. There is a custom class inherited from System.Net.Sockets.SocketAsyncEventArgs class. Something like the following: public class SocketTaskArgs : SocketAsyncEventArgs { public SocketTaskArgs() { …
Marek Takac
  • 1,105
  • 7
  • 11
5
votes
1 answer

TcpListener vs SocketAsyncEventArgs

Is there a valid reason to not use TcpListener for implementing a high performance/high throughput TCP server instead of SocketAsyncEventArgs? I've already implemented this high performance/high throughput TCP server using SocketAsyncEventArgs went…
Kaveh Shahbazian
  • 13,088
  • 13
  • 80
  • 139
4
votes
1 answer

Timeouts on async socket communication with SocketAsyncEventArgs

I'm using SocketAsyncEventArgs to communicate with hundreds of equipments (most of them through GPRS). Sometimes, some of them stop responding and it seems I have no way of timing out the operation, as the documentation states that the timeout…
Fernando
  • 4,029
  • 1
  • 26
  • 35
3
votes
3 answers

How to use Socket.SendAsync to send large data

private void ProcessReceive(SocketAsyncEventArgs e) { // Check if the remote host closed the connection. if (e.BytesTransferred > 0) { if (e.SocketError == SocketError.Success) { Token token = e.UserToken as…
DannyQiu
  • 31
  • 1
  • 1
  • 2
3
votes
0 answers

c# Socket.AcceptAsync where is Socket.StopAcceptAsync?

There is AcceptAsync for Socket. Code looks like this: private Socket _listeningSocket; private SocketAsyncEventArgs _socketEvent; private Init() { _socketEvent = new SocketAsyncEventArgs(); _listeningSocket = ...; // Set up ip, port etc. …
Anna Melashkina
  • 422
  • 2
  • 13
3
votes
1 answer

BeginReceive/SocketAsyncEventArgs list of ArraySegments

What is the reasoning behind passing a list of ArraySegment to Socket.BeginReceive/SocketAsyncEventArgs? MSDN for the Socket.BeginReceive constructor doesn't even correctly describe the first argument): public IAsyncResult BeginReceive( …
Lou
  • 4,244
  • 3
  • 33
  • 72
3
votes
1 answer

Is it worth to pool SocketAsyncEventArgs for reuse in this scenario?

In my scenario, there are many clients' tcp sockets connected to the server.The server ReceiveAsync() from all sockets and when the callback is called without error, parse the received data. If one socket's received data is an certain type of…
tianyi
  • 109
  • 6
3
votes
1 answer

Sending data in order with SocketAsyncEventArgs

I originally had a race condition when sending data, the issue was that I was allowing multiple SocketAsyncEventArgs to be used to send data, but the first packet didn't send fully before the 2nd packet, this is because I have it so if the data…
Matty
  • 37
  • 1
  • 8
3
votes
1 answer

SocketAsyncEventArgs? - simple example

As the progress of my XNA TopDown Shooter game continues, it's time to implement multiplayer functionality. Because the client and server will have to handle alot of data per second (60 packets per second with position, rotation and other player…
Basaa
  • 151
  • 2
  • 13
2
votes
1 answer

How to cancel custom awaitable

I've read Stephen Toub's blog about making a custom awaitable for SocketAsyncEventArgs. This works all fine. But what I need is a cancellable awaitable and the blog doesn't cover this topic. Also Stephen Cleary unfortunately doesn't cover in his…
Josh
  • 287
  • 1
  • 8
2
votes
0 answers

Share send byte[] buffer among multiple SocketAsyncEventArgs

In a scenario where I always send the same data to many clients, i.e. in a scenario where I should (and in the future will) probably switch to using (e.g. PGM) multicast, would it be thread-safe to use the the same byte[] array instance on multiple…
Evgeniy Berezovsky
  • 18,571
  • 13
  • 82
  • 156
1
2 3 4