Please understand that C++ is not a language designed for the creation of such programs. To make that sort of program involves interaction with the operation system, device drivers, which is rather difficult. I suggest you start learning some programming in order to have a valid idea of what programming is.
If you need a simple firewall, I suggest downloading one of the many free ones online.
thank you for your reply .
actually I want some thing to block packets and I thought to block ports is something benefit .
is there any other idea to block traffic .