I'm using POE to read from a socket when something is available, then do a bunch of stuff with it. I'm using select_read() to tell me if something is available on the socket. This call is documented in POE::Kernel as follows:
I would like to use the optional arguments to communicate with my event handler. To do this, I created the following line in my event handler:# Watch for read readiness on a filehandle. $kernel->select_read( $file_handle, $event, @optional_args );
I was expecting $optarg1 to be the first optional argument that I set in the select_read call. Instead, it always seemed to be set to zero. I searched a bunch, but didn't find anything, then asked in the CB for some help. I had to run before anyone had time to help me out, so I thought I'd post the question here.($k, $sock, $optarg1) = @_[KERNEL, ARG0, ARG1];
While getting my references setup for this article, I stumbled across the solution in POE::Kernel:
D'oh! As you can see, my problem is solved by the following:Select events include two parameters. ARG0 holds the handle of the file that is ready. ARG1 contains 0, 1, or 2 to indicate whether the filehandle is ready f +or reading, writing, or out-of-band reading (otherwise knows as "expe +dited" or "exception"). ARG2..$#_ contain optional additional parameters passed to POE::Kernel +'s various I/O watcher methods.
Thanks to all who tried to help out in CB. I hope this helps others who walk down the same path I did.($k, $sock, $status, $optarg1) = @_[KERNEL, ARG0, ARG1, ARG2];
-Craig
In reply to Accessing POE select_read optinal_args - Solved by cmv
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |