Select

E

Eder Quiñones

Hi, I'm working with sockets and I want to know when I'm able to send
and receive data, this is what I Have:

def receive
select(nil, [@socket], nil, 0)
end

def send
select([@socket], nil, nil, 0)
end

Anyone knows how to improve this?.
 
R

Roger Pack

Eder said:
Hi, I'm working with sockets and I want to know when I'm able to send
and receive data, this is what I Have:

def receiveableRightNow
r,w,e = select([@socket], nil, nil, 0)
return !r.empty? # r is an array -- if it has @socket in it then
@socket is able to receive

end

I think :)

That's how I do it. If there's a better way like a built in function I
dunno.
 

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
474,264
Messages
2,571,318
Members
48,003
Latest member
coldDuece

Latest Threads

Top