Created
November 11, 2011 12:08
-
-
Save kentaro/1357857 to your computer and use it in GitHub Desktop.
使ってないポートを取得する (Perl) ref: http://qiita.com/items/1018
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
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use v5.14; | |
use IO::Socket::INET;sub empty_port () { | |
my $sock = IO::Socket::INET->new( | |
Prot => 'tcp', | |
Listen => 1, | |
(($^O eq 'MSWin32') ? () : (ReuseAddr => 1)), | |
); | |
my $port = $sock->sockport; | |
$sock->close; | |
$port; | |
}say empty_port; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment