I need some advices please

  • Thread starter Thread starter Nico
  • Start date Start date
N

Nico

Hello everyone,

I have re-formulated the question I asked on my last post::

I am trying to capture the System event raised when a Network Connection
is established in VB.NET (ie. connection from a client to a network
resource, just like the winsock control did successfully for so many years)
AND the one that is raised when data is recieved on this connection. I have
seen many posts suggesting to create a timer and check the network status
(or even use endless loop instead of a timer) but I find this much too
resource hungry for my requirements.

I want to catch the event when it arrises, just like Winsock did or the
event listeners in Java. I know there is a way to do this, I believe it
exists, Microsoft are not the kind of enterprise to start from something
that works well (ie: winsock) and go backward to the flinstone's era (ie:
using an endless loop or a timer to pool again and again and again and eat
all your precious CPU time... The interrupt controler on the PC isn't there
just for the good looking, it have it's purpose and one of them is to "Tell"
that something happened on that or that part pf the hardware, etc.). This
was once implemented and I don't see why this would have disapeared just
like this.

Perhaps I can listen to Windows messages or something like that (if I knew
what to listen for!).

I have tried search MSDN, Google and this newsgroup for a working solution
(Without the loops / timers) but have not been successful.

Any help/code would be greatly appreciated.

Thanks

Nico
 
You can monitor windows messages, but it sounds like your looking for a
global hook scenario...

Now, I'm still learning how windows message pumps work so I may be wrong in
this but I'll attempt it nonethless..

You could try using the System.Windows.Forms.Application.AddMessageFilter
method to intercept windows messages, but I don't know if that will
intercept all of them.. or if its possible. But that way you could monitor
IF you could find which message you were looking for...

http://www.mangovision.com/vbapi/ref/msgc.html

here is a list of windows messages, but I don't know if it will provide you
what you want.

The second way is to start a separate thread and poll WMI every 5 seconds or
so using the System.Management namespace.

Thats about all the advice I can offer.

-CJ
 
You set up the Main listener as a base class that listens for the connection, this on the acceptConnection spawn another class that accepts data and processes it. Once the spawned class is finised with the processing you can disconnect it. This would mean that the server class would only be lisening and the pass the rest of the processing power to the client class that you spawned

I have been working on something like this for an online Game engine, but with me I would be sending data to the client all the time and recieveing a pulse to make sure that the connection is still open, if no connection is there I release the connection and thread

Glenn
 
Back
Top