move mac os detection to a function
add function to get next available tcp/ip port