You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
api-approvedAPI was approved in API review, it can be implementedarea-System.Net.Socketsin-prThere is an active PR which will close this issue when it is merged
Currently the PAL layer blocks unknown options; eventually they may become adopted as enums, however prior to that it would be useful to be able to pass them through in an unvalidated manner.
publicpartialclassSocket{// existing: public void SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, byte[] optionValue);publicvoidSetRawSocketOption(intoptionLevel,intoptionName,ReadOnlySpan<byte>optionValue);// existing: public byte[] GetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, int optionLength);publicintGetRawSocketOption(intoptionLevel,intoptionName,Span<byte>optionValue);}
Anyone had success using this workaround to set SO_ATTACH_FILTER? I've been trying to do it for several hours and keep getting back -1. Assuming it's because I'm attempting to build the bpf filter from structs and bypassing libpcap's pcap_compile method.
I do think this API is useful but I personally think we should not have this API in the framework since there is no way we can ever support this correctly on all platforms in uniform way. I'd prefer if someone wanting to set any options just did their own interop. Socket.Handle can be used to get native handle. I don't feel super strongly about this and it will be area owners final decision anyway :-)
@krwq why couldn't we support it? the support contract here is very minimal "we aren't managing platform for you, we just forward the params to interop layer".
api-approvedAPI was approved in API review, it can be implementedarea-System.Net.Socketsin-prThere is an active PR which will close this issue when it is merged
Activity
benaadams commentedon Apr 23, 2019
Current workaround is to pinvoke e.g. on linux
and then use
setsockopt((int)socket.Handle, ....geoffkizer commentedon Apr 24, 2019
Presumably you would want GetRawSocketOption too?
benaadams commentedon Apr 24, 2019
Yes :)
wfurt commentedon Apr 24, 2019
and Bind() ? Can and Raw family would need them.
wfurt commentedon Apr 25, 2019
cc: @krwq may be related to dotnet/corefx#35143
los93sol commentedon Jun 18, 2019
Anyone had success using this workaround to set SO_ATTACH_FILTER? I've been trying to do it for several hours and keep getting back -1. Assuming it's because I'm attempting to build the bpf filter from structs and bypassing libpcap's pcap_compile method.
karelz commentedon Sep 9, 2019
I would suggest to use
SetPlatformOptionname.krwq commentedon Sep 9, 2019
I do think this API is useful but I personally think we should not have this API in the framework since there is no way we can ever support this correctly on all platforms in uniform way. I'd prefer if someone wanting to set any options just did their own interop. Socket.Handle can be used to get native handle. I don't feel super strongly about this and it will be area owners final decision anyway :-)
scalablecory commentedon Oct 8, 2019
@krwq why couldn't we support it? the support contract here is very minimal "we aren't managing platform for you, we just forward the params to interop layer".
scalablecory commentedon Oct 22, 2019
Do we need unsafe here? How about span?
benaadams commentedon Oct 22, 2019
I'd be ok with that; updated summary
scalablecory commentedon Oct 29, 2019
triage: not sure about naming, should we have GetRawSocketOption? ready for review.
also thinking about: RawBind
terrajobst commentedon Feb 20, 2020
Video
TryGetRawSocketOptionbut we can't think of a case where the size of the option would change/is not known.