Hello,
I am not sure if it is going to work but I have heard that you can use winsock control to watch the connections. If you can write a program, which command the winsock to send a message or close the port when something is transfering, I think it is going to work. I have seen good toturials about winsock in www.directhit.com. this is a very good search engine. Try it.