Outgoing TCP/IP connection using a randomized port and causing a conflict
For outgoing TCP/IP connection, unless a client program explicitly requests a specific port number, the port number used is an ephemeral port number. Ephemeral ports are temporary ports assigned by a machine's IP stack, and are assigned from a designated range of ports for this purpose. To avoid conflict, adjust the range of ephermeral ports according to requirement
Instructions for the correspondent operating system.
Increase the range of ephemeral ports by setting the MaxUserPort TCP/IP parameter to an higher value (like 32768), on the windows registry key HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters, as a DWORD value. This will set the port range from 1024 to 32768.
Windows 2008 R2
Increase the range of ephemeral ports by setting the dynamicportrange to an higher value through the command netsh int ipv4 set dynamicportrange tcp start=32767 num=65535, this will set the port range from 32768 to 65535.
Redhat LInux 5
Increase the range of ephemeral ports by setting ip_local_port_range kernel value on /proc/sys/net/ipv4/ip_local_port_range, using the command echo "32768 65535" > /proc/sys/net/ipv4/ip_local_port_range, this will set the port range from 32768 to 65535.
The kernel value parameters aren't saved with these commands, and are reset to the default values on system reboot, thus make sure to place the commands on a system startup script such as /etc/rc.local.