Fix handling of ports over 32767 by using 'int' instead of 'short'.