API to start and stop the http https ftp port

I heard that it is possible to write a custom service to start and stop http / https / ftp listening port. I did some quick search in advantage and this website but did not find anything. Can someone please point me in the right direction?

Thanks
pp

I don’t have code that does this on hand, but I’ll ask you a question to point you in the right direction.

How does WmRoot/pub/security-ports.dsp do it?