Note that in order to get a version of an external program that can be run under a debugger, you need to compile the program so that the output is suitable for use with your debugger. Unix compilers commonly use -g as a command-line argument for producing a debuggable program. See your compiler documentation for specific information on the steps you should take.
Set a breakpoint in the C function f.
break f Breakpointset:f:line1
Start the external program.
run -linkcreate -linkprotocol TCPIP
The program responds with what port it is listening on.