Created
          November 28, 2014 10:32 
        
      - 
      
- 
        Save hazzik/edd28a7129f820b4579b to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | using System; | |
| using System.Net; | |
| using System.Net.Sockets; | |
| using System.Threading; | |
| class Program | |
| { | |
| static void Main() | |
| { | |
| for (int i = 0; i < 1000; i++) | |
| { | |
| new Thread(() => | |
| { | |
| var listener = new TcpListener(IPAddress.Loopback, 0); // <s>RTFM</s> MSDN | |
| listener.Start(); | |
| var port = ((IPEndPoint)listener.LocalEndpoint).Port; | |
| Console.WriteLine(port); | |
| }).Start(); | |
| } | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment