The logic here is wrong - you should assign the return value to a separate variable.

I think this code will fail to behave as expected for port 0 or 80!