0

I want to create an app to block IP Address. I read Microsoft docs about Winsock then I know about setsockopt() function. This function has an attribute level that has an option SO_CONDITIONAL_ACCEPT. The Description of this option is can enable incoming connections are to be accepted or rejected by the application, not by the protocol stack (https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-setsockopt)

But I don't know how to set it to auto block my Input that is an IP Address. Or do you know any function in Winsock that can block outbound connections please tell me. Thank all!

Alex K.
  • 171,639
  • 30
  • 264
  • 288
Noob
  • 23
  • 3
  • 1
    Assuming you want to block at the *machine* level then Winsock is not the correct approach, the features you have quoted only relate to the individual process thats calling it not all processes. Intead consider the firewall API, E.g. https://stackoverflow.com/questions/9712814/updating-existing-firewall-rule-using-api – Alex K. Feb 02 '22 at 14:22
  • `SO_CONDITIONAL_ACCEPT` is used only by TCP servers that want to filter *incoming* connections by application-defined criteria in a `WSAAccept()` callback. See https://learn.microsoft.com/en-us/windows/win32/winsock/so-conditional-accept for details. Alex is correct, you need a firewall for what you are asking. It is literally the sole job of a firewall to block connections. – Remy Lebeau Feb 02 '22 at 15:52
  • thank you, but I cannot find any help in stackoverflow about windows firewall api C++. I want to block IP address through firewall api in C++, how can I do? – Noob Feb 03 '22 at 11:39

0 Answers0