TCP/IP in C#
-
Suppose someone were writing a "firewall" application that was "watching" or listening for activity over an incoming IP address, what is the best way to cover all ports. In all the examples I have read, someone creates an instance of TcpListener and supplies a port to listen to. Surely you don't have to do that for each of the 65,000+ ports. Could someone lead me in the right direction. Thanks. :confused: Nick Parker
-
Suppose someone were writing a "firewall" application that was "watching" or listening for activity over an incoming IP address, what is the best way to cover all ports. In all the examples I have read, someone creates an instance of TcpListener and supplies a port to listen to. Surely you don't have to do that for each of the 65,000+ ports. Could someone lead me in the right direction. Thanks. :confused: Nick Parker
There is probably some winsock/system hook buried somewhere deep in the win32 API, that tells you when there is an inbound connection request. I looked at SetWindowsHookEx but it didn't seem to offer it, and I didn't see anything in the WinSock API. Perhaps someone more knowledgeable than me can fill you in, in the VC++ forum. Once you find it, you can use P/Invoke to access it. Or at the most you would have to write a MC++ layer to act as the middleman for your C# code and the system. Good Luck, James Sonork: Hasaki "I left there in the morning with their God tucked underneath my arm their half-assed smiles and the book of rules. So I asked this God a question and by way of firm reply, He said - I'm not the kind you have to wind up on Sundays." "Wind Up" from Aqualung, Jethro Tull 1971
-
There is probably some winsock/system hook buried somewhere deep in the win32 API, that tells you when there is an inbound connection request. I looked at SetWindowsHookEx but it didn't seem to offer it, and I didn't see anything in the WinSock API. Perhaps someone more knowledgeable than me can fill you in, in the VC++ forum. Once you find it, you can use P/Invoke to access it. Or at the most you would have to write a MC++ layer to act as the middleman for your C# code and the system. Good Luck, James Sonork: Hasaki "I left there in the morning with their God tucked underneath my arm their half-assed smiles and the book of rules. So I asked this God a question and by way of firm reply, He said - I'm not the kind you have to wind up on Sundays." "Wind Up" from Aqualung, Jethro Tull 1971
James T. Johnson wrote: There is probably some winsock/system hook buried somewhere deep in the win32 API So you think a system hook is the way to go?? :confused: This might be a great article idea, when I find more time/information I will post something, I tried the VC++ forum but only got one response that was unfortunately no help. I'll keep searching :) Nick Parker