Most codebases have a variable somewhere near the main() function called 'port'. Often the arguments passed to the MUD are parsed and used to set the port number. Take a look at ROM in the main() function. It'll be there.
In comm.c, the main function, is explicitly sets the port to 4000…. why is this? Why doesn't it draw from the startup script? Is this why when I run GDB it runs on port 4000 every time? Why don't I have problems connecting to port 9000?
In the SMAUG derived code I use, the base port is a cset option (ie, it is an in game setting). If you do supply a port on the command line, it will auto become the base port, or you can set it in game with the cset command doing a live port switch. If you want to find out what it is set to, you can use the cset command in game to show it (along with the other system settings), or offline (or if you just like to work in the shell) look in the system.dat file.