in reply to Re^3: A non-blocking server using 'select' calls
in thread A non-blocking server using 'select' calls

I've tried it on my system, and it gets inside the while loop only when a newline character is send to the server. $client->can_read returns only when a newline character is received. I tried telnet and netcat as clients. It turns out the problem is not with sysread or recv but can_read. Thanks.

Replies are listed 'Best First'.
Re^5: A non-blocking server using 'select' calls
by tachyon (Chancellor) on Nov 11, 2004 at 11:47 UTC

    It's not. Add $|++; to the top of your script. I have tested that server on Win2K, WinXp, RH7, Fedora2 and it works as advertised. On Linux you need the $|++ as print passes through STDIO and gets buffered. It will work if you replace the print with syswrite( STDOUT, $_, 1 ) as well.

    cheers

    tachyon

      I know it sounds weird. I've tried changing $|. Nothing happens. It still waits for a newline.
      -bash-2.05b$ uname -a FreeBSD gateway.intra 5.2-CURRENT FreeBSD 5.2-CURRENT #1: Tue Aug 3 1 +4:26:12 MSD 2004 root@gateway.intra:/usr/obj/usr/src/sys/My i386 -bash-2.05b$ perl -v This is perl, v5.6.1 built for i386-freebsd
        It is a STDIO buffering thing. s/print;/syswrite(STDOUT,$_,1)/ and bypass it completely.