Call Server Connect in Custom Module

Here you have it for node. I guess the concept is the same for php. Check the exec function for php in the core files.