v1_9_3_125 - Show latest stable - 0 notes - Class: Socket
udp_server_sockets(host=nil, port) public

Creates UDP/IP sockets for a UDP server.

If no block given, it returns an array of sockets.

If a block is given, the block is called with the sockets. The value of the block is returned. The sockets are closed when this method returns.

If port is zero, some port is choosen. But the choosen port is used for the all sockets.

# UDP/IP echo server
Socket.udp_server_sockets(0) {|sockets|
  p sockets.first.local_address.ip_port     #=> 32963
  Socket.udp_server_loop_on(sockets) {|msg, msg_src|
    msg_src.reply msg
Show source
Register or log in to add new notes.