Class: BasicSocket
- Inherits:
-
IO
show all
- Defined in:
- lib/neverblock/io/socket.rb
Direct Known Subclasses
Socket
Constant Summary
collapse
- @@getaddress_method =
IPSocket.method(:getaddress)
Constants inherited
from IO
IO::NB_BUFFER_LENGTH
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from IO
#getc, #gets, #print, #rb_getc, #rb_gets, #rb_print, #rb_read, #rb_readchar, #rb_readline, #rb_readlines, #rb_sysread, #rb_syswrite, #rb_write, #read, #read_neverblock, #readchar, #readline, #readlines, #readpartial, #sysread, #syswrite, #write, #write_neverblock
Class Method Details
.getaddress(*args) ⇒ Object
12
13
14
|
# File 'lib/neverblock/io/socket.rb', line 12
def self.getaddress(*args)
@@getaddress_method.call(*args)
end
|
Instance Method Details
#recv(*args) ⇒ Object
32
33
34
35
36
37
38
|
# File 'lib/neverblock/io/socket.rb', line 32
def recv(*args)
if NB.neverblocking?
recv_neverblock(*args)
else
recv_blocking(*args)
end
end
|
#recv_blocking ⇒ Object
16
|
# File 'lib/neverblock/io/socket.rb', line 16
alias_method :recv_blocking, :recv
|
#recv_neverblock(*args) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/neverblock/io/socket.rb', line 18
def recv_neverblock(*args)
res = ""
begin
old_flags = self.fcntl(Fcntl::F_GETFL, 0)
res << recv_nonblock(*args)
self.fcntl(Fcntl::F_SETFL, old_flags)
rescue Errno::EWOULDBLOCK, Errno::EAGAIN, Errno::EINTR
self.fcntl(Fcntl::F_SETFL, old_flags)
NB.wait(:read, self)
retry
end
res
end
|