PATH:
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Socket
U:RDoc::AnyMethod[iI"recvfrom_nonblock:ETI"Socket#recvfrom_nonblock;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"IReceives up to _maxlen_ bytes from +socket+ using recvfrom(2) after ;TI";O_NONBLOCK is set for the underlying file descriptor. ;TI"4_flags_ is zero or more of the +MSG_+ options. ;TI"EThe first element of the results, _mesg_, is the data received. ;TI"OThe second element, _sender_addrinfo_, contains protocol-specific address ;TI"information of the sender.;To:RDoc::Markup::BlankLine o; ; [ I"CWhen recvfrom(2) returns 0, Socket#recv_nonblock returns nil. ;TI"OIn most cases it means the connection was closed, but for UDP connections ;TI"Kit may mean an empty packet was received, as the underlying API makes ;TI"2it impossible to distinguish these two cases.;T@S:RDoc::Markup::Heading: leveli: textI"Parameters;To:RDoc::Markup::List: @type:BULLET:@items[ o:RDoc::Markup::ListItem:@label0; [o; ; [I"F+maxlen+ - the maximum number of bytes to receive from the socket;To;;0; [o; ; [I"1+flags+ - zero or more of the +MSG_+ options;To;;0; [o; ; [I")+outbuf+ - destination String buffer;To;;0; [o; ; [I"9+opts+ - keyword hash, supporting `exception: false`;T@S;; i;I"Example;To:RDoc::Markup::Verbatim; [ I"%# In one file, start this first ;TI"require 'socket' ;TI"include Socket::Constants ;TI"2socket = Socket.new(AF_INET, SOCK_STREAM, 0) ;TI"6sockaddr = Socket.sockaddr_in(2200, 'localhost') ;TI"socket.bind(sockaddr) ;TI"socket.listen(5) ;TI"-client, client_addrinfo = socket.accept ;TI"'begin # emulate blocking recvfrom ;TI"+ pair = client.recvfrom_nonblock(20) ;TI"rescue IO::WaitReadable ;TI" IO.select([client]) ;TI" retry ;TI" end ;TI"data = pair[0].chomp ;TI"/puts "I only received 20 bytes '#{data}'" ;TI" sleep 1 ;TI"socket.close ;TI" ;TI"*# In another file, start this second ;TI"require 'socket' ;TI"include Socket::Constants ;TI"2socket = Socket.new(AF_INET, SOCK_STREAM, 0) ;TI"6sockaddr = Socket.sockaddr_in(2200, 'localhost') ;TI"socket.connect(sockaddr) ;TI"-socket.puts "Watch this get cut short!" ;TI"socket.close ;T:@format0o; ; [I"PRefer to Socket#recvfrom for the exceptions that may be thrown if the call ;TI""to _recvfrom_nonblock_ fails.;T@o; ; [I"XSocket#recvfrom_nonblock may raise any error corresponding to recvfrom(2) failure, ;TI""including Errno::EWOULDBLOCK.;T@o; ; [ I">If the exception is Errno::EWOULDBLOCK or Errno::EAGAIN, ;TI")it is extended by IO::WaitReadable. ;TI"KSo IO::WaitReadable can be used to rescue the exceptions for retrying ;TI"recvfrom_nonblock.;T@o; ; [I"OBy specifying a keyword argument _exception_ to +false+, you can indicate ;TI"Pthat recvfrom_nonblock should not raise an IO::WaitReadable exception, but ;TI"0return the symbol +:wait_readable+ instead.;T@S;; i;I"See;To;;;;[o;;0; [o; ; [I"Socket#recvfrom;T: @fileI"ext/socket/lib/socket.rb;T:0@omit_headings_from_table_of_contents_below0I"\socket.recvfrom_nonblock(maxlen[, flags[, outbuf[, opts]]]) => [mesg, sender_addrinfo] ;T0[ I"0(len, flag = 0, str = nil, exception: true);T@mFI"Socket;TcRDoc::NormalClass00
[-] getifaddrs-c.ri
[edit]
[-] unpack_sockaddr_in-c.ri
[edit]
[-] tcp_without_fast_fallback-c.ri
[edit]
[-] pair-c.ri
[edit]
[-] udp_server_loop-c.ri
[edit]
[-] getservbyname-c.ri
[edit]
[-] udp_server_loop_on-c.ri
[edit]
[-] unix-c.ri
[edit]
[-] tcp_with_fast_fallback-c.ri
[edit]
[-] sockaddr_un-c.ri
[edit]
[-] cdesc-Socket.ri
[edit]
[-] ip_address%3f-c.ri
[edit]
[-] current_clock_time-c.ri
[edit]
[-] tcp-c.ri
[edit]
[-] udp_server_recv-c.ri
[edit]
[-] bind-i.ri
[edit]
[-] connect_nonblock-i.ri
[edit]
[-] socketpair-c.ri
[edit]
[-] unix_server_socket-c.ri
[edit]
[-] new-c.ri
[edit]
[-] gethostbyaddr-c.ri
[edit]
[-] accept-i.ri
[edit]
[-] udp_server_sockets-c.ri
[edit]
[-] getnameinfo-c.ri
[edit]
[-] sockaddr_in-c.ri
[edit]
[-] gethostname-c.ri
[edit]
[-] listen-i.ri
[edit]
[-] tcp_fast_fallback-c.ri
[edit]
[-] unpack_sockaddr_un-c.ri
[edit]
[-] recvfrom-i.ri
[edit]
[-] pack_sockaddr_in-c.ri
[edit]
[+]
UDPSource
[+]
AncillaryData
[+]
HostnameResolutionStore
[-] expired%3f-c.ri
[edit]
[-] unix_socket_abstract_name%3f-c.ri
[edit]
[-] tcp_server_loop-c.ri
[edit]
[-] sysaccept-i.ri
[edit]
[+]
Constants
[-] ipv6only%21-i.ri
[edit]
[-] ip_address_list-c.ri
[edit]
[+]
..
[-] second_to_timeout-c.ri
[edit]
[+]
Ifaddr
[-] pack_sockaddr_un-c.ri
[edit]
[-] accept_loop-c.ri
[edit]
[-] connect-i.ri
[edit]
[-] resolve_hostname-c.ri
[edit]
[+]
ResolutionError
[-] tcp_server_sockets-c.ri
[edit]
[-] unix_server_loop-c.ri
[edit]
[-] tcp_fast_fallback%3d-c.ri
[edit]
[-] gethostbyname-c.ri
[edit]
[-] accept_nonblock-i.ri
[edit]
[-] getservbyport-c.ri
[edit]
[+]
Option
[-] recvfrom_nonblock-i.ri
[edit]
[+]
HostnameResolutionResult
[-] getaddrinfo-c.ri
[edit]