views:

399

answers:

0

I've been experimenting with many TCP Socket projects found on the Internet. The 'Server' class will often accept 'multiple clients', but only one connection at a time due to 'Single Port' usage restrictions. I've discovered Winsock responds differently on Visa than XP. The Visa Winsock will redirect the same incoming port to a random, unused port allowing the 'Server' to accept continuous data flow from multiple Clients. Whereas XP does NOT reliably perform port translation/forwarding very well. Generally porting more that one client fails after a few minutes. The C# programs never return socket exception errors, only a generic Error: 5000 appears in the OS event logs. I know each client could use a different port, but this doesn' seem very practical.

Q. Is there a way to perform port translation/forwarding within a C# class running as a windows service?

  1. Client will always request same port(6500).
  2. Server will connect if port is available.
  3. Server will 'Increment' busy port number and connect client.

Here is a typical C# TCP Socket Async code example using 'Main' socket, 'Worker' socket design. http://www.codeguru.com/csharp/csharp/cs_network/sockets/article.php/c7695