Answer
If you install a server application that uses TCP IP protocol for communication, it is better to know whether or not the port you want to use is free before the installation starts. Using Advanced Installer, you can make this check using the CheckTCPPort predefined custom action.
Go to the Custom Actions page and add the
predefined UI Custom Action "Check TCP Port".

Go to the Dialog Editor page.
Create a new dialog called
"CheckFreeTCPPort", added after "WelcomeDlg" in the dialogs tree.

Bind the port Edit control to the AI_BIND_TCP_PORT property. The Check TCP Port custom action gets the port that will be checked from AI_BIND_TCP_PORT property.

Call the Check TCP Port custom action when the "Next" button is clicked. To do that, the "Next" button must publish a DoAction control event with "CheckFreeTCPPort" argument. Verify the return of the check and display a message if the port is used by another application. Do not go to the next dialog in the chain if the port is used. To display the message, create a new spawn dialog and publish a SpawnDialog control event.

Sample Project
You can find a small sample Advanced Installer project implementing the above
functionality here.