Questions tagged [asyncsocket]

Asynchronous sockets allow for multiple simultaneous non-blocking socket connections.

Asynchronous sockets allow for multiple socket connections within a single thread. While more complicated than synchronous sockets, asyncsockets allow for more efficient use of cpu scheduling. These connections are non-blocking, which allows the main program thread to continue running, while a socket thread manages network traffic.

589 questions
29
votes
2 answers

Is it possible to remove ExecutionContext and Thread allocations when using SocketAsyncEventArgs?

If you profile a simple client application that uses SocketAsyncEventArgs, you will notice Thread and ExecutionContext allocations. The source of the allocations is SocketAsyncEventArgs.StartOperationCommon that creates a copy of the…
cao
  • 997
  • 9
  • 17
27
votes
4 answers

Java Non-Blocking and Asynchronous IO with NIO & NIO.2 (JSR203) - Reactor/Proactor Implementations

So here I am reading one of my favorite software pattern books (Pattern-Oriented Software Architecture - Patterns for Concurrent and Networked Objects), specifically the sections on Proactor/Reactor asynchronous IO patterns. I can see how by using…
S73417H
  • 2,661
  • 3
  • 23
  • 37
22
votes
2 answers

How to keep the android client connected to the server even on activity changes and send data to server?

I initially implemented an async task in my activity which sends data to the server. But when i changed activities the connection was lost. To avoid this my approach was to implement a service that centralizes the network operation and sends data to…
gfernandes
  • 1,156
  • 3
  • 12
  • 29
21
votes
1 answer

What's the difference between async and nonblocking in unix socket?

I'm seeing such code in nginx: if(fcntl(ngx_processes[s].channel[0], F_SETFL, fcntl(s, F_GETFL) | O_NONBLOCK) == -1) { ... if (ioctl(ngx_processes[s].channel[0], FIOASYNC, &on) == -1) { ... Anyone can tell me what's the difference between fcntl(s,…
cpuer
  • 7,413
  • 14
  • 35
  • 39
21
votes
2 answers

High-performance TCP Socket programming in .NET C#

I know this topic is already asked sometimes, and I have read almost all threads and comments, but I'm still not finding the answer to my problem. I'm working on a high-performance network library that must have TCP server and client, has to be able…
beatcoder
  • 683
  • 1
  • 5
  • 19
20
votes
5 answers

C# UDP Socket: Get receiver address

I have an asynchronous UDP server class with a socket bound on IPAddress.Any, and I'd like to know which IPAddress the received packet was sent to (...or received on). It seems that I can't just use the Socket.LocalEndPoint property, as it always…
chezy525
  • 4,025
  • 6
  • 28
  • 41
20
votes
2 answers

What does make significant difference of performance between eventlet and gevent?

Those two libraries share the similar philosophy and the similar design decisions as a result. But this popular WSGI benchmark says eventlet is way slower than gevent. What do make their performance so different? As I know key differences between…
minhee
  • 5,688
  • 5
  • 43
  • 81
17
votes
2 answers

Why is it taking so long to GC System.Threading.OverlappedData?

I'm running my application through a memory profiler to check for leaks. Things seem to be sort of OK, but I'm getting a lot of these OverlappedData that seems to be hanging around in the finalizer queue doing next to nothing. They are the result of…
Dervall
  • 5,736
  • 3
  • 25
  • 48
14
votes
2 answers

How to determine if a given request is running?

I'm looking at retrofit for my networking layer. Is there any way to tell if a particular async request is running at any given moment? For example, I'd like to know if a request is running so that I can update the user interface at various times. I…
user3203425
  • 2,919
  • 4
  • 29
  • 48
13
votes
2 answers

How does an asynchronous socket server work?

I should state that I'm not asking about specific implementation details (yet), but just a general overview of what's going on. I understand the basic concept behind a socket, and need clarification on the process as a whole. My (probably very…
w.brian
  • 16,296
  • 14
  • 69
  • 118
10
votes
3 answers

Waiting on a condition (pthread_cond_wait) and a socket change (select) simultaneously

I'm writing a POSIX compatible multi-threaded server in c/c++ that must be able to accept, read from, and write to a large number of connections asynchronously. The server has several worker threads which perform tasks and occasionally (and…
10
votes
3 answers

Visual Studio 2010 doesn’t stop at an unhandled exception inside a Socket.BeginReceive() callback - why?

Normally, when the debugger is attached, Visual Studio 2010 stops at an unhandled exception even if the Exceptions dialog doesn’t have the tickmark for the exception type in the “Thrown” column. The keyword here is unhandled; said dialog refers only…
Timwi
  • 65,159
  • 33
  • 165
  • 230
10
votes
4 answers

AsyncUdpSocket how to use receive

I am trying to get a program for iPhone running on the simulator. My problem is with receiving UDP data. I use asyncUdpSocket. If I make a socket and use sendData:(NSData) toHost:,... well it works fine. The think i can just not figure out is how…
Saren Inden
  • 3,450
  • 4
  • 32
  • 45
10
votes
2 answers

Why is the Completed callback from SocketAsyncEventArgs frequently executed in newly created threads instead of using a bounded thread pool?

I have a simple client application that receives byte buffers from the network with a low throughput. Here is the code: private static readonly HashSet _capturedThreadIds = new HashSet(); private static void RunClient(Socket socket) { …
cao
  • 997
  • 9
  • 17
9
votes
1 answer

Is it safe to wrap NetworkStream with BufferedStream for async reading?

I'm using NetworkStream.BeginRead to read asynchronously from a Socket. But it is much faster if you actually wrap the network stream with a BufferedStream. My question: NetworkStream.BeginRead internally invokes to Socket.BeginReceive and the whole…
pablo
  • 6,392
  • 4
  • 42
  • 62
1
2 3
39 40