The global variable server_portnum controls on which TCP port the server will accept incoming connections. The default server port number 6267 is assigned by IANA (see IANA TCP port listing for details).
The server port number is used only when the server begins listening for incoming connections. Once the listen process is started, the server port number can be changed, but that will not have any affect on the listen process.
If the port number desired is already in use, GridLAB-D will increment the port by 1 and try again until it can find an available port.
In a GLM file you can control the server port number using the directive:
From the command line, you can set the port number using the --server_portnum or -P options:
host% gridlabd -P number -or- host% gridlabd --server_portnum number
The default server port number is establish in core/globals.h. At runtime, this can be changed in the gridlabd.conf file by adding the directive: