Permalink
Browse files

Merge branch 'master' of git@github.com:tokuhirom/perl-echo-servers

  • Loading branch information...
2 parents 8f14208 + 5b0861b commit 911ae370fffc09b94ac794ce96aabd3a83f6d894 @tokuhirom committed Sep 28, 2009
Showing with 4 additions and 0 deletions.
  1. +4 −0 echo-epoll.pl
View
@@ -1,6 +1,7 @@
use strict;
use warnings;
use Getopt::Long;
+use Socket qw(IPPROTO_TCP TCP_NODELAY);
use IO::Socket::INET;
use IO::Epoll;
use Fcntl;
@@ -89,8 +90,11 @@ sub with_perlio {
my $sock = $listener->accept;
my $sock_fd = fileno $sock;
$Sock_Holder[$sock_fd] = $sock;
+
+ setsockopt($sock, IPPROTO_TCP, TCP_NODELAY, 1);
my $flags = fcntl($sock, F_GETFL, 0) or die "fcntl GET_FL: $!";
fcntl($sock, F_SETFL, $flags|O_NONBLOCK) or die "fcntl SET_FL: $!";
+
epoll_ctl($epfd, EPOLL_CTL_ADD, $sock_fd, EPOLLIN) >= 0
|| die "epoll_ctl: $!\n";
} else {

0 comments on commit 911ae37

Please sign in to comment.