initialize port only if addr is not NULL