Last post Oct 23, 2017 03:31 PM by Radomir
Oct 23, 2017 11:41 AM|Jakub Polkowski|LINK
I'm currently working with C# on .net core 2 on:
- x86 windows,
- x86 linux,
- ARM linux
I would like to use raw socket in my C# solution.
On windows everything works fine, on linux (x86 and ARM) i get en error:
" Unhandled Exception: System.Net.Sockets.SocketException: Protocol not supported
at System.Net.Sockets.Socket..ctor(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType) "
Some code that throws that exception:
mainSocket = new Socket(AddressFamily.InterNetwork,SocketType.Raw, ProtocolType.IP);
And my question is:
1st. - It this possible to get a raw socket using C# and .net 2 on any linux distribution?
2nd. - If not how to get a raw data from physical network interface under linux using C# ?
Oct 23, 2017 02:26 PM|Radomir|LINK
Have you tried ProtocolType.Tcp?
That error you're seeing is only thrown here:
Oct 23, 2017 02:57 PM|Jakub Polkowski|LINK
THX, it works now, i need to check is there any difference in work between ProtocolType.IP on Windows and ProtocolType.Tcp on Linux.... ( my target is to capture all possible packets on the interface like udp, icmp, igmp etc... ).
One more question - how did you get that this should be Tcp ? I can't find this in any documentation ...
Once again thank You very much :)
Oct 23, 2017 03:31 PM|Radomir|LINK
Saw it here:
it's an old post but was worth trying :)