Skip to content

Instantly share code, notes, and snippets.

@hazzik
Created November 28, 2014 10:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hazzik/edd28a7129f820b4579b to your computer and use it in GitHub Desktop.
Save hazzik/edd28a7129f820b4579b to your computer and use it in GitHub Desktop.
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