Posted By

jx_boi on 08/30/10


Tagged

port


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

Vordreller
Tyster
ovuncgursoy


GetAvailablePort


 / Published in: C#
 

  1. public static int GetAvailablePort()
  2. {
  3. TcpListener list = new TcpListener(0);
  4. list.Start();
  5. int port = (list.LocalEndpoint as IPEndPoint).Port;
  6. list.Stop();
  7. return port;
  8. }

Report this snippet  

You need to login to post a comment.