U:RDoc::AnyMethod[iI" recvfrom:ETI"Socket#recvfrom;TF: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [ I"JReceives up to _maxlen_ bytes from +socket+. _flags_ is zero or more ;TI"Rof the +MSG_+ options. The first element of the results, _mesg_, is the data ;TI"Qreceived. The second element, _sender_addrinfo_, contains protocol-specific ;TI"'address information of the sender.;To:RDoc::Markup::BlankLineS: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;T@S; ; i;I" Example;To:RDoc::Markup::Verbatim; [I"%# In one file, start this first ;TI"require 'socket' ;TI"include Socket::Constants ;TI"4socket = Socket.new( AF_INET, SOCK_STREAM, 0 ) ;TI"=sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' ) ;TI"socket.bind( sockaddr ) ;TI"socket.listen( 5 ) ;TI"-client, client_addrinfo = socket.accept ;TI"+data = client.recvfrom( 20 )[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"4socket = Socket.new( AF_INET, SOCK_STREAM, 0 ) ;TI"=sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' ) ;TI" socket.connect( sockaddr ) ;TI"-socket.puts "Watch this get cut short!" ;TI"socket.close ;T: @format0S; ; i;I"Unix-based Exceptions;To; ; [I"VOn unix-based based systems the following system exceptions may be raised if the ;TI"call to _recvfrom_ fails:;To;;;;[o;;0; [o; ; [ I"QErrno::EAGAIN - the +socket+ file descriptor is marked as O_NONBLOCK and no ;TI"Odata is waiting to be received; or MSG_OOB is set and no out-of-band data ;TI"Gis available and either the +socket+ file descriptor is marked as ;TI"FO_NONBLOCK or the +socket+ does not support blocking to wait for ;TI"out-of-band-data;To;;0; [o; ; [I"+Errno::EWOULDBLOCK - see Errno::EAGAIN;To;;0; [o; ; [I"?Errno::EBADF - the +socket+ is not a valid file descriptor;To;;0; [o; ; [I"CErrno::ECONNRESET - a connection was forcibly closed by a peer;To;;0; [o; ; [I"MErrno::EFAULT - the socket's internal buffer, address or address length ;TI""cannot be accessed or written;To;;0; [o; ; [I"QErrno::EINTR - a signal interrupted _recvfrom_ before any data was available;To;;0; [o; ; [I"QErrno::EINVAL - the MSG_OOB flag is set and no out-of-band data is available;To;;0; [o; ; [I"MErrno::EIO - an i/o error occurred while reading from or writing to the ;TI"filesystem;To;;0; [o; ; [I"MErrno::ENOBUFS - insufficient resources were available in the system to ;TI"perform the operation;To;;0; [o; ; [I"MErrno::ENOMEM - insufficient memory was available to fulfill the request;To;;0; [o; ; [I"KErrno::ENOSR - there were insufficient STREAMS resources available to ;TI"complete the operation;To;;0; [o; ; [I"OErrno::ENOTCONN - a receive is attempted on a connection-mode socket that ;TI"is not connected;To;;0; [o; ; [I">Errno::ENOTSOCK - the +socket+ does not refer to a socket;To;;0; [o; ; [I"SErrno::EOPNOTSUPP - the specified flags are not supported for this socket type;To;;0; [o; ; [I"QErrno::ETIMEDOUT - the connection timed out during connection establishment ;TI"=or due to a transmission timeout on an active connection;T@S; ; i;I"Windows Exceptions;To; ; [I"IOn Windows systems the following system exceptions may be raised if ;TI""the call to _recvfrom_ fails:;To;;;;[o;;0; [o; ; [I"*Errno::ENETDOWN - the network is down;To;;0; [o; ; [I"QErrno::EFAULT - the internal buffer and from parameters on +socket+ are not ;TI"Jpart of the user address space, or the internal fromlen parameter is ;TI".too small to accommodate the peer address;To;;0; [o; ; [I"MErrno::EINTR - the (blocking) call was cancelled by an internal call to ;TI"/the WinSock function WSACancelBlockingCall;To;;0; [o; ; [I"PErrno::EINPROGRESS - a blocking Windows Sockets 1.1 call is in progress or ;TI"Athe service provider is still processing a callback function;To;;0; [o; ; [ I"NErrno::EINVAL - +socket+ has not been bound with a call to _bind_, or an ;TI"Lunknown flag was specified, or MSG_OOB was specified for a socket with ;TI"PSO_OOBINLINE enabled, or (for byte stream-style sockets only) the internal ;TI"3len parameter on +socket+ was zero or negative;To;;0; [o; ; [I"OErrno::EISCONN - +socket+ is already connected. The call to _recvfrom_ is ;TI"Jnot permitted with a connected socket on a socket that is connection ;TI" oriented or connectionless.;To;;0; [o; ; [I"MErrno::ENETRESET - the connection has been broken due to the keep-alive ;TI"Factivity detecting a failure while the operation was in progress.;To;;0; [o; ; [ I"QErrno::EOPNOTSUPP - MSG_OOB was specified, but +socket+ is not stream-style ;TI"Nsuch as type SOCK_STREAM. OOB data is not supported in the communication ;TI"Hdomain associated with +socket+, or +socket+ is unidirectional and ;TI""supports only send operations;To;;0; [o; ; [I"JErrno::ESHUTDOWN - +socket+ has been shutdown. It is not possible to ;TI"Ccall _recvfrom_ on a socket after _shutdown_ has been invoked.;To;;0; [o; ; [I"KErrno::EWOULDBLOCK - +socket+ is marked as nonblocking and a call to ;TI"_recvfrom_ would block.;To;;0; [o; ; [I"RErrno::EMSGSIZE - the message was too large to fit into the specified buffer ;TI"and was truncated.;To;;0; [o; ; [I"NErrno::ETIMEDOUT - the connection has been dropped, because of a network ;TI"Ffailure or because the system on the other end went down without ;TI" notice;To;;0; [o; ; [ I"JErrno::ECONNRESET - the virtual circuit was reset by the remote side ;TI"Jexecuting a hard or abortive close. The application should close the ;TI"Isocket; it is no longer usable. On a UDP-datagram socket this error ;TI"Nindicates a previous send operation resulted in an ICMP Port Unreachable ;TI" message.;T: @fileI"ext/socket/socket.c;T:0@omit_headings_from_table_of_contents_below0I"rsocket.recvfrom(maxlen) => [mesg, sender_addrinfo] socket.recvfrom(maxlen, flags) => [mesg, sender_addrinfo] ;T0[I" (*args);T@ðFI" Socket;TcRDoc::NormalClass00