Okay...let me rephrase that.... lol... I know which sockets are being used because my Firewall program lets me know... and C source code is something I dont really want to touch - Im a novice at C and C++; C# is my strong language; the problem is that the ports my program uses varies... and the IP address it connects to changes... so one execution of the code may be 138.56.118.41:108, the next execution of the program may be 138.56.118:109 - I have no control over that... System.Management does that for me... I guess what Im saying is these programs like the one you mentioned Plaus relates a port to a program; I need to do basically the same thing... and I guess Ill have to end up researching that... then shut the ports down myself... the whole point to the original post was that this is a managed set of classes that shouldnt act like this but they are and its frustrating me as to why?! Dispose should shut down the ports being used by that class... I shouldnt have to do the clean up work myself!
But to tell the truth the solution I am currently using works, as ugly as it may be. I have two EXEs basically... one is the main program, the second is a program that does the WMI stuff... The second program is a process that I start from the main program and is invisible so it only shows up in task manager, it does the work returns a completion code, then my main program (which is in the Process.WaitForCompletion state or whatever it is) gets focus back and based on that return process the information the other program created, this keeps my ports open only when they should be... its ugly... but it works. Ill look into how to detect ports that a program is using later or look at some examples... but right now as ugly as it may be, it works, Ill finese it later. Thanks!