Fixed bug-incorrect port being passed to a function