From 7f3f4923ec711ec97a1204ec2c080e219f50ff3b Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 2 Sep 2019 04:51:31 +0000 Subject: tests: add tcp_connect() helper IO::Socket::INET->new is rather verbose with the options hash, extract it into a standalone sub --- t/httpd.t | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 't/httpd.t') diff --git a/t/httpd.t b/t/httpd.t index e0a2bf44..47ba7acc 100644 --- a/t/httpd.t +++ b/t/httpd.t @@ -9,8 +9,7 @@ foreach my $mod (qw(Plack::Util Plack::Builder HTTP::Date HTTP::Status)) { plan skip_all => "$mod missing for httpd.t" if $@; } use File::Temp qw/tempdir/; -use IO::Socket::INET; -use Socket qw(IPPROTO_TCP); +use Socket qw(IPPROTO_TCP SOL_SOCKET); require './t/common.perl'; # FIXME: too much setup @@ -58,10 +57,7 @@ EOF $pid = spawn_listener(undef, $cmd, [$sock]); my $host = $sock->sockhost; my $port = $sock->sockport; - my $conn = IO::Socket::INET->new(PeerAddr => $host, - PeerPort => $port, - Proto => 'tcp', - Type => SOCK_STREAM); + my $conn = tcp_connect($sock); ok($conn, 'connected'); ok($conn->write("GET / HTTP/1.0\r\n\r\n"), 'wrote data to socket'); { -- cgit v1.2.3-24-ge0c7