--- !ruby/object:RI::MethodDescription aliases: [] block_params: comment: - !ruby/struct:SM::Flow::P body: Receives up to maxlen bytes from udpsocket using recvfrom(2) after O_NONBLOCK is set for the underlying file descriptor. flags is zero or more of the MSG_ options. The first element of the results, mesg, is the data received. The second element, sender_inet_addr, is an array to represent the sender address. - !ruby/struct:SM::Flow::P body: When recvfrom(2) returns 0, Socket#recvfrom_nonblock returns an empty string as data. It means an empty packet. - !ruby/struct:SM::Flow::H level: 3 text: Parameters - !ruby/object:SM::Flow::LIST contents: - !ruby/struct:SM::Flow::LI label: "*" body: maxlen - the number of bytes to receive from the socket - !ruby/struct:SM::Flow::LI label: "*" body: flags - zero or more of the MSG_ options type: :BULLET - !ruby/struct:SM::Flow::H level: 3 text: Example - !ruby/struct:SM::Flow::VERB body: " require 'socket'\n s1 = UDPSocket.new\n s1.bind("127.0.0.1", 0)\n s2 = UDPSocket.new\n s2.bind("127.0.0.1", 0)\n s2.connect(*s1.addr.values_at(3,1))\n s1.connect(*s2.addr.values_at(3,1))\n s1.send "aaa", 0\n IO.select([s2])\n p s2.recvfrom_nonblock(10) #=> ["aaa", ["AF_INET", 33302, "localhost.localdomain", "127.0.0.1"]]\n" - !ruby/struct:SM::Flow::P body: Refer to Socket#recvfrom for the exceptions that may be thrown if the call to recvfrom_nonblock fails. - !ruby/struct:SM::Flow::P body: UDPSocket#recvfrom_nonblock may raise any error corresponding to recvfrom(2) failure, including Errno::EAGAIN. - !ruby/struct:SM::Flow::H level: 3 text: See - !ruby/object:SM::Flow::LIST contents: - !ruby/struct:SM::Flow::LI label: "*" body: Socket#recvfrom type: :BULLET full_name: UDPSocket#recvfrom_nonblock is_singleton: false name: recvfrom_nonblock params: | udpsocket.recvfrom_nonblock(maxlen) => [mesg, sender_inet_addr] udpsocket.recvfrom_nonblock(maxlen, flags) => [mesg, sender_inet_addr] visibility: public