added port calculation for host.cpp