1

My dedicated server has 5 usable, static IP addresses. This server's primary objective is to create and maintain several hundred connections to a single destination. Understandably, after a few hundred connections have been established, I am confronted with socket read/write exceptions and mass disconnects. This likely occurs because the destination either recognizes the single origin IP address and temporarily blocks it, or because the single link between A and B becomes unstable.

In effect, I'd like to witness the results of dividing the connections between multiple source IP addresses.

My research so far has led me to questions and answers like this one, which suggest using ServicePoint.BindIPEndPointDelegate.

However, I would like to bind the entire console app to a specific IP address. How do I accomplish this?

Note: I am using FluorineFX at the moment. If a solution exists to tell FluorineFX which IP address to make connections from, that would work as well.

Community
  • 1
  • 1
Joshua Jones
  • 35
  • 1
  • 5
  • You can't bind an entire process for good reason: You'd affect even innocent/bystanding components of your process. It would be a global setting for a local problem. – usr Jan 23 '13 at 23:59
  • @usr Then how do I go about using all 5 IP addresses? Do I need to use Hyper-V and assign each instance 1 IP address, then run these processes in the contained environment? – Joshua Jones Jan 25 '13 at 01:49
  • The answer under this question is correct. It will allow you to use any IP(s) you want. – usr Jan 25 '13 at 13:05

1 Answers1

1

It's quite easy to specify the source IP address when using the TCP functionality in .NET. If you're using TcpClient, simply use the TcpClient(IPEndPoint localEndPoint) constructor, which will bind it to the specified local IP address. For connections made using the Socket class, you need to use the Bind(EndPoint localEP) method on the socket to associate it with a local address.

Iridium
  • 23,323
  • 6
  • 52
  • 74