udp_server_recv

Socket.udp_server_recv(sockets) {|msg, msg_src| ... }
Class Public methods

Receive UDP/IP packets from the given sockets. For each packet received, the block is called.

The block receives msg and msg_src. msg is a string which is the payload of the received packet. msg_src is a Socket::UDPSource object which is used for reply.

::udp_server_loop can be implemented using this method as follows.

udp_server_sockets(host, port) {|sockets|
  loop {
    readable, _, _ = IO.select(sockets)
    udp_server_recv(readable) {|msg, msg_src| ... }
  }
}
doc_ruby_on_rails
2015-05-15 06:35:57
Comments
Leave a Comment

Please login to continue.