added check for APNET_PORT env var