git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2009-02-11 08:49:49 +00:00
Родитель 83eddaad27
Коммит a2c779be35
1 изменённых файлов: 13 добавлений и 7 удалений

Просмотреть файл

@ -279,7 +279,7 @@ class Socket
# creates TCP server sockets for _host_ and _port_. # creates TCP server sockets for _host_ and _port_.
# _host_ is optional. # _host_ is optional.
# #
# If a block is not given, # If no block given,
# it returns an array of listening sockets. # it returns an array of listening sockets.
# #
# If a block is given, the block is called with the sockets. # If a block is given, the block is called with the sockets.
@ -421,16 +421,22 @@ class Socket
# Socket.udp_server_sockets([host, ] port) # Socket.udp_server_sockets([host, ] port)
# #
# Creates UDP sockets for a UDP server. # Creates UDP sockets for a UDP server.
# It returns an array of sockets. #
# 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. # If _port_ is zero, some port is choosen.
# But the choosen port is used for the all sockets. # But the choosen port is used for the all sockets.
# #
# # UDP echo server # # UDP echo server
# sockets = Socket.udp_server_sockets(0) # Socket.udp_server_sockets(0) {|sockets|
# p sockets.first.local_address.ip_port #=> 32963 # p sockets.first.local_address.ip_port #=> 32963
# Socket.udp_server_loop_on(sockets) {|msg, msg_src| # Socket.udp_server_loop_on(sockets) {|msg, msg_src|
# msg_src.reply msg # msg_src.reply msg
# }
# } # }
# #
def self.udp_server_sockets(host=nil, port) def self.udp_server_sockets(host=nil, port)
@ -612,7 +618,7 @@ class Socket
# creates UNIX server sockets on _path_ # creates UNIX server sockets on _path_
# #
# If a block is not given, it returns a listening socket. # If no block given, it returns a listening socket.
# #
# If a block is given, it is called with the socket and the block value is returned. # If a block is given, it is called with the socket and the block value is returned.
# When the block exits, the socket is closed and the socket file is removed. # When the block exits, the socket is closed and the socket file is removed.