----- Original Message -----
From: Orlando Andico
To: The Main Philippine Linux Users' Group (PLUG) Discussion List
Sent: Monday, November 21, 2005 2:45 PM
Subject: Re: [plug] Perl: handling blocking reads "nicely"
> i'm not so sure if this will "work" consistently if there's a huge lot of
> message traffic though.
it will work... however it will not timeout and always in ready state if
there is a single byte of data incoming within your timeout value...
that's ok. because a single byte would not be meaningful anyway (a "well-formed" message packet has many, many bytes in it).
if you want to implement socket timeout... you have three options and these
are...
1. as what you did.. using alarm function..
2. using either select or poll function...
computationally expensive. :P
basically reduced to polling. unless there's a (smallish) timeout value in the call to select so that the process has time to sleep.
i thought i'd left this stuff behind with the end of my C-coding days!!! :P
3. using the newer SO_RCVTIMEO and SO_SNDTIMEO socket options... take note
that not all implementations support these two socket options...
if you dont want to implement socket timeout... you can set the socket
filedescriptor default from blocking state into non-block state using
O_NONBLOCK flag in fcntl() function...
O_NONBLOCK is worse. now THAT's real polling. CPU hog. MS-DOS style coding. :)
_________________________________________________ Philippine Linux Users' Group (PLUG) Mailing List [email protected] (#PLUG @ irc.free.net.ph) Read the Guidelines: http://linux.org.ph/lists Searchable Archives: http://archives.free.net.ph

