kerryjiang / WebSocket4Net

A popular .NET WebSocket Client
Apache License 2.0
764 stars 273 forks source link

Is it asynchronous? #55

Open ghost opened 8 years ago

ghost commented 8 years ago

Let's say I'm accepting packets from multiple machines, each packet should be responded, but the response is a bit slow... say it takes 20 seconds for each packet.

Will it still receive packets even if WebSocket_MessageReceived is blocked?

FANAT-- commented 7 years ago

sponger94, no, it will not.

WebSocket use Socket.ReceiveAsync(SocketAsyncEventArgs e) method. This method sets callback on event from I/O completion port. So, your handler _WebSocketMessageReceived is executed every time in some threadpool's thread. BUT WebSocket itself will start recieving new packets (will call another Socket.ReceiveAsync) only when your handler will be completed.