diff --git a/lib/HTTP/Server/PSGI.pm b/lib/HTTP/Server/PSGI.pm index 7d9d81ef4..186e6997b 100644 --- a/lib/HTTP/Server/PSGI.pm +++ b/lib/HTTP/Server/PSGI.pm @@ -13,11 +13,13 @@ use Plack::Util; use Stream::Buffered; use Plack::Middleware::ContentLength; use POSIX qw(EINTR); -use Socket qw(IPPROTO_TCP TCP_NODELAY); +use Socket qw(IPPROTO_TCP); use Try::Tiny; use Time::HiRes qw(time); +use constant TCP_NODELAY => try { Socket::TCP_NODELAY }; + my $alarm_interval; BEGIN { if ($^O eq 'MSWin32') { @@ -105,8 +107,10 @@ sub accept_loop { while (1) { local $SIG{PIPE} = 'IGNORE'; if (my $conn = $self->{listen_sock}->accept) { - $conn->setsockopt(IPPROTO_TCP, TCP_NODELAY, 1) - or die "setsockopt(TCP_NODELAY) failed:$!"; + if (defined TCP_NODELAY) { + $conn->setsockopt(IPPROTO_TCP, TCP_NODELAY, 1) + or die "setsockopt(TCP_NODELAY) failed:$!"; + } my $env = { SERVER_PORT => $self->{port}, SERVER_NAME => $self->{host},