V
Vorxion
I'm having a problem with select() on a socket. I'm setting the bits, and
it's really strange, because even when there's -nothing- to be read,
vec($rout,fileno(DATA) comes back as 0 instead of 1. The bits come back
0 1 0 in order of $rout $wout $eout.
Okay, so exactly how do you tell when the remote end is sitting there with
nothing to say? I've used select(2) in C, and there appears to be no ready
equivalent of FD_ISSET() in perl.
If someone can tell me how to do this properly, or what I'm doing wrong (I'm
checking for $rout to be set back to 0 (via vec) after the select(). It was
working this morning with one set of test conditions, but now it isn't with
another set of test conditions. Now it always comes back 0, which can't
be right, unless I'm doing something wrong due to underdocumentation.
# Set flags for select().
$rin = $win = $rout = $wout = $ein = $eout = '';
vec($rin,fileno(DATA),1) = 1;
vec($win,fileno(DATA),1) = 1;
$ein = ${rin} | ${win};
# Actually check our socket for data.
print("BEFORE SELECT\n") if ${debug};
select($rout=$rin,$wout=$win,$eout=$ein,${timeout_select});
print("PAST SELECT\n") if ${debug};
print("TIMEOUT AND rVEC: ${timeout} ", vec(${rout},fileno(DATA),1),"\n");
print("TIMEOUT AND wVEC: ${timeout} ", vec(${wout},fileno(DATA),1),"\n");
print("TIMEOUT AND eVEC: ${timeout} ", vec(${eout},fileno(DATA),1),"\n");
Basically, I need to know when there is data waiting for me, and when there is
no data waiting for me. I -thought- checking for $rout to be 0 via vec() was
the way you emulate FD_ISSET, but I must be mistaken.
Help?
it's really strange, because even when there's -nothing- to be read,
vec($rout,fileno(DATA) comes back as 0 instead of 1. The bits come back
0 1 0 in order of $rout $wout $eout.
Okay, so exactly how do you tell when the remote end is sitting there with
nothing to say? I've used select(2) in C, and there appears to be no ready
equivalent of FD_ISSET() in perl.
If someone can tell me how to do this properly, or what I'm doing wrong (I'm
checking for $rout to be set back to 0 (via vec) after the select(). It was
working this morning with one set of test conditions, but now it isn't with
another set of test conditions. Now it always comes back 0, which can't
be right, unless I'm doing something wrong due to underdocumentation.
# Set flags for select().
$rin = $win = $rout = $wout = $ein = $eout = '';
vec($rin,fileno(DATA),1) = 1;
vec($win,fileno(DATA),1) = 1;
$ein = ${rin} | ${win};
# Actually check our socket for data.
print("BEFORE SELECT\n") if ${debug};
select($rout=$rin,$wout=$win,$eout=$ein,${timeout_select});
print("PAST SELECT\n") if ${debug};
print("TIMEOUT AND rVEC: ${timeout} ", vec(${rout},fileno(DATA),1),"\n");
print("TIMEOUT AND wVEC: ${timeout} ", vec(${wout},fileno(DATA),1),"\n");
print("TIMEOUT AND eVEC: ${timeout} ", vec(${eout},fileno(DATA),1),"\n");
Basically, I need to know when there is data waiting for me, and when there is
no data waiting for me. I -thought- checking for $rout to be 0 via vec() was
the way you emulate FD_ISSET, but I must be mistaken.
Help?