Hiii,
Im no expert but wouldnt that involve starting and stopping services on your system? And closing them would also involve getting a Firewall of some sort!!!

For Instance if you want port 21 Run a FTP server on your machine. OPEN PORT 21
or maybe Closing port 139 Disabling file and print sharing.

You getting the idea? Or am i off on your question!

Tasha