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?.
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?.
Eder Quiñones wrote:
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.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs