select() on socket

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? :)
 
B

Brian McCauley

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.
Eh?

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().
select($rout=$rin,$wout=$win,$eout=$ein,${timeout_select});

You are not checking if the return value of select().

It is possible that it's failing.

--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
 
V

Vorxion

You are not checking if the return value of select().

It is possible that it's failing.

Yes, I discovered that in the wee hours of last night. Fixed. It helped
to go through the core modules and look at how it was used there.

Now I need to find a way to determine if the socket has been closed from
remote. Now that I have the return value of select being used, maybe I can
try using EBITS?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,151
Latest member
JaclynMarl
Top