Socket.Receive

  • Thread starter Thread starter Alexander Muylaert
  • Start date Start date
A

Alexander Muylaert

Hi

I their a way I can interupt socket.Receive.

I want my multi-threader server to be able to handle requests as wel as
Broadcast messages. This broadcasting is done when the socket is not
handling a request.

How can I do something like this

ManualResetEvent OutgoingRequest;

WaitHandle.WaitAny(new WaitHandle[]{Socket.IncomingData, OutgoingRequest})

Anybody has a tip for this? In Win32 this was fairly simple since
Overlapped IO contained an event anyway.

How do I do this in .net?

Kind regards

Alexander
 
Alexander,

Have you considered using the BeginSend and BeginAccept methods on the
Socket to do this asynchrnously? It should be fairly easy, and the
asynchronous model uses Overlapped IO beneath the covers.

Hope this helps.
 
You can have one thread doing accepts and a writer thread doing writes. Not
sure if broadcasting allows this or not. See Winsock Faq to be sure.
 
I have

But, and please correct me, I think these use the threadpool. The
threadpool has like X threads. so when I launch X simultanious reads the
threadpool is full and new requests are going to fail?

What happens when I do async read on let's say 100 sockets simultanious?

kind regards

Alexander


Nicholas Paldino said:
Alexander,

Have you considered using the BeginSend and BeginAccept methods on the
Socket to do this asynchrnously? It should be fairly easy, and the
asynchronous model uses Overlapped IO beneath the covers.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Alexander Muylaert said:
Hi

I their a way I can interupt socket.Receive.

I want my multi-threader server to be able to handle requests as wel as
Broadcast messages. This broadcasting is done when the socket is not
handling a request.

How can I do something like this

ManualResetEvent OutgoingRequest;

WaitHandle.WaitAny(new WaitHandle[]{Socket.IncomingData,
OutgoingRequest})

Anybody has a tip for this? In Win32 this was fairly simple since
Overlapped IO contained an event anyway.

How do I do this in .net?

Kind regards

Alexander
 
When you issue an asynchronous read request on a socket, an overlapped I/O
request is issued on the socket. The internal thread pool uses a completion
port to monitor the completion of the operation. No threads from the thread
pool are used until the overlapped I/O completes and your asychronous
callback is invoked. You could have 10000 outstanding read operations and
not have a single thread active. Bottom line, threads are only used when
the operation completes.

Regards,

Joel

Alexander Muylaert said:
I have

But, and please correct me, I think these use the threadpool. The
threadpool has like X threads. so when I launch X simultanious reads the
threadpool is full and new requests are going to fail?

What happens when I do async read on let's say 100 sockets simultanious?

kind regards

Alexander


Nicholas Paldino said:
Alexander,

Have you considered using the BeginSend and BeginAccept methods on the
Socket to do this asynchrnously? It should be fairly easy, and the
asynchronous model uses Overlapped IO beneath the covers.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Alexander Muylaert said:
Hi

I their a way I can interupt socket.Receive.

I want my multi-threader server to be able to handle requests as wel as
Broadcast messages. This broadcasting is done when the socket is not
handling a request.

How can I do something like this

ManualResetEvent OutgoingRequest;

WaitHandle.WaitAny(new WaitHandle[]{Socket.IncomingData,
OutgoingRequest})

Anybody has a tip for this? In Win32 this was fairly simple since
Overlapped IO contained an event anyway.

How do I do this in .net?

Kind regards

Alexander
 
Back
Top