I
I.P. Freely
Greetings my dear friend,
Let's say I wanted to write an application that talks directly to a
network card. For example, say I'm designing a firewall or packet sniffer.
Do I need to use unmanaged code to do this? I'm wondering how I should
arrange the "division of labor" between managed and unmanaged code.
Let's make the example even simpler by saying that I want to design a
form with a button on it. When the button is clicked, I want to send a
packet out the ethernet card. The packet needs to be sent by talking
directly to the Ethernet card drivers, not via a standard interface like
Winsock [yes, I know that there's no practical reason to design such an
application -- it's just an example]..
So my goal is to make all of my code "managed" except what absolutely
MUST be unmanaged. So the form would be designed in C# -- as would be the
handler for the button... but when the button is clicked, I'll need to talk
to a network driver. So at that point, I'll need to use unmanaged C++ (??).
How would I handle this? As far as I know, I can't mix managed C# and
unmanaged C++ in the same assembly (can I?)... Would I design a totally
separate C++ DLL which exposes a SendPacket() method?
I'm not asking for any specific code, just general *concepts* that I can
research further in the online help, books, etc. I'm just not sure where to
begin.
I.P. Freely
Let's say I wanted to write an application that talks directly to a
network card. For example, say I'm designing a firewall or packet sniffer.
Do I need to use unmanaged code to do this? I'm wondering how I should
arrange the "division of labor" between managed and unmanaged code.
Let's make the example even simpler by saying that I want to design a
form with a button on it. When the button is clicked, I want to send a
packet out the ethernet card. The packet needs to be sent by talking
directly to the Ethernet card drivers, not via a standard interface like
Winsock [yes, I know that there's no practical reason to design such an
application -- it's just an example]..
So my goal is to make all of my code "managed" except what absolutely
MUST be unmanaged. So the form would be designed in C# -- as would be the
handler for the button... but when the button is clicked, I'll need to talk
to a network driver. So at that point, I'll need to use unmanaged C++ (??).
How would I handle this? As far as I know, I can't mix managed C# and
unmanaged C++ in the same assembly (can I?)... Would I design a totally
separate C++ DLL which exposes a SendPacket() method?
I'm not asking for any specific code, just general *concepts* that I can
research further in the online help, books, etc. I'm just not sure where to
begin.
I.P. Freely