udp_server_loop

Socket.udp_server_loop(port) {|msg, msg_src| ... }
Socket.udp_server_loop(host, port) {|msg, msg_src| ... }
Class Public methods

creates a UDP/IP server on port and calls the block for each message arrived. The block is called with the message and its source information.

This method allocates sockets internally using port. If host is specified, it is used conjunction with port to determine the server addresses.

The msg is a string.

The msg_src is a Socket::UDPSource object. It is used for reply.

# UDP/IP echo server.
Socket.udp_server_loop(9261) {|msg, msg_src|
  msg_src.reply msg
}
doc_ruby_on_rails
2015-05-15 06:24:19
Comments
Leave a Comment

Please login to continue.