mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	update doc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27012 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									0edceaa7c7
								
							
						
					
					
						commit
						652484598d
					
				
					 11 changed files with 62 additions and 36 deletions
				
			
		| 
						 | 
				
			
			@ -1769,6 +1769,10 @@ rsock_bsock_recvmsg_nonblock(int argc, VALUE *argv, VALUE sock)
 | 
			
		|||
 | 
			
		||||
/*
 | 
			
		||||
 * Document-class: ::Socket::AncillaryData
 | 
			
		||||
 *
 | 
			
		||||
 * Socket::AncillaryData represents the ancillary data (control information)
 | 
			
		||||
 * used by sendmsg and recvmsg system call.
 | 
			
		||||
 * It contains socket family, cmsg level, cmsg type and cmsg data.
 | 
			
		||||
 */
 | 
			
		||||
void
 | 
			
		||||
Init_ancdata(void)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -89,7 +89,7 @@ bsock_shutdown(int argc, VALUE *argv, VALUE sock)
 | 
			
		|||
 * call-seq:
 | 
			
		||||
 *   basicsocket.close_read => nil
 | 
			
		||||
 *
 | 
			
		||||
 * Disallows further read.
 | 
			
		||||
 * Disallows further read using shutdown system call.
 | 
			
		||||
 *
 | 
			
		||||
 *   s1, s2 = UNIXSocket.pair
 | 
			
		||||
 *   s1.close_read
 | 
			
		||||
| 
						 | 
				
			
			@ -117,7 +117,7 @@ bsock_close_read(VALUE sock)
 | 
			
		|||
 * call-seq:
 | 
			
		||||
 *   basicsocket.close_write => nil
 | 
			
		||||
 *
 | 
			
		||||
 * Disallows further write.
 | 
			
		||||
 * Disallows further write using shutdown system call.
 | 
			
		||||
 *
 | 
			
		||||
 *   UNIXSocket.pair {|s1, s2|
 | 
			
		||||
 *     s1.print "ping"
 | 
			
		||||
| 
						 | 
				
			
			@ -198,7 +198,8 @@ bsock_close_write(VALUE sock)
 | 
			
		|||
 *   };
 | 
			
		||||
 * 
 | 
			
		||||
 * In this case #setsockopt could be called like this:
 | 
			
		||||
 *   optval =  IPAddr.new("224.0.0.251").hton + IPAddr.new(Socket::INADDR_ANY, Socket::AF_INET).hton
 | 
			
		||||
 *   optval = IPAddr.new("224.0.0.251").hton +
 | 
			
		||||
 *            IPAddr.new(Socket::INADDR_ANY, Socket::AF_INET).hton
 | 
			
		||||
 *   sock.setsockopt(Socket::IPPROTO_IP, Socket::IP_ADD_MEMBERSHIP, optval)
 | 
			
		||||
 *
 | 
			
		||||
*/
 | 
			
		||||
| 
						 | 
				
			
			@ -263,7 +264,7 @@ bsock_setsockopt(int argc, VALUE *argv, VALUE sock)
 | 
			
		|||
 *
 | 
			
		||||
 * Gets a socket option. These are protocol and system specific, see your
 | 
			
		||||
 * local system documentation for details. The option is returned as
 | 
			
		||||
 * a Socket::Option.
 | 
			
		||||
 * a Socket::Option object.
 | 
			
		||||
 *
 | 
			
		||||
 * === Parameters
 | 
			
		||||
 * * +level+ is an integer, usually one of the SOL_ constants such as
 | 
			
		||||
| 
						 | 
				
			
			@ -349,7 +350,8 @@ bsock_getsockopt(VALUE sock, VALUE lev, VALUE optname)
 | 
			
		|||
 *     p serv.getsockname #=> "\x02\x00;\x10\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00"
 | 
			
		||||
 *   }
 | 
			
		||||
 *
 | 
			
		||||
 * If Addrinfo object is preferred, use BasicSocket#local_address.
 | 
			
		||||
 * If Addrinfo object is preferred over the binary string,
 | 
			
		||||
 * use BasicSocket#local_address.
 | 
			
		||||
 */
 | 
			
		||||
static VALUE
 | 
			
		||||
bsock_getsockname(VALUE sock)
 | 
			
		||||
| 
						 | 
				
			
			@ -376,7 +378,8 @@ bsock_getsockname(VALUE sock)
 | 
			
		|||
 *     p s.getpeername #=> "\x02\x00\x82u\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00"
 | 
			
		||||
 *   }
 | 
			
		||||
 *
 | 
			
		||||
 * If Addrinfo object is preferred, use BasicSocket#remote_address.
 | 
			
		||||
 * If Addrinfo object is preferred over the binary string,
 | 
			
		||||
 * use BasicSocket#remote_address.
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
static VALUE
 | 
			
		||||
| 
						 | 
				
			
			@ -458,6 +461,10 @@ bsock_getpeereid(VALUE self)
 | 
			
		|||
 *
 | 
			
		||||
 * Note that addrinfo.protocol is filled by 0.
 | 
			
		||||
 *
 | 
			
		||||
 *   TCPSocket.open("www.ruby-lang.org", 80) {|s|
 | 
			
		||||
 *     p s.local_address #=> #<Addrinfo: 192.168.0.129:36873 TCP>
 | 
			
		||||
 *   }
 | 
			
		||||
 *
 | 
			
		||||
 *   TCPServer.open("127.0.0.1", 1512) {|serv|
 | 
			
		||||
 *     p serv.local_address #=> #<Addrinfo: 127.0.0.1:1512 TCP>
 | 
			
		||||
 *   }
 | 
			
		||||
| 
						 | 
				
			
			@ -484,6 +491,10 @@ bsock_local_address(VALUE sock)
 | 
			
		|||
 *
 | 
			
		||||
 * Note that addrinfo.protocol is filled by 0.
 | 
			
		||||
 *
 | 
			
		||||
 *   TCPSocket.open("www.ruby-lang.org", 80) {|s|
 | 
			
		||||
 *     p s.remote_address #=> #<Addrinfo: 221.186.184.68:80 TCP>
 | 
			
		||||
 *   }
 | 
			
		||||
 *
 | 
			
		||||
 *   TCPServer.open("127.0.0.1", 1728) {|serv|
 | 
			
		||||
 *     c = TCPSocket.new("127.0.0.1", 1728)
 | 
			
		||||
 *     s = serv.accept
 | 
			
		||||
| 
						 | 
				
			
			@ -506,7 +517,7 @@ bsock_remote_address(VALUE sock)
 | 
			
		|||
 | 
			
		||||
/*
 | 
			
		||||
 * call-seq:
 | 
			
		||||
 *   basicsocket.send(mesg, flags [, sockaddr_to]) => numbytes_sent
 | 
			
		||||
 *   basicsocket.send(mesg, flags [, dest_sockaddr]) => numbytes_sent
 | 
			
		||||
 *
 | 
			
		||||
 * send _mesg_ via _basicsocket_.
 | 
			
		||||
 *
 | 
			
		||||
| 
						 | 
				
			
			@ -514,7 +525,7 @@ bsock_remote_address(VALUE sock)
 | 
			
		|||
 *
 | 
			
		||||
 * _flags_ should be a bitwise OR of Socket::MSG_* constants.
 | 
			
		||||
 *
 | 
			
		||||
 * _sockaddr_to_ should be a packed sockaddr string or an addrinfo.
 | 
			
		||||
 * _dest_sockaddr_ should be a packed sockaddr string or an addrinfo.
 | 
			
		||||
 *
 | 
			
		||||
 *   TCPSocket.open("localhost", 80) {|s|
 | 
			
		||||
 *     s.send "GET / HTTP/1.0\r\n\r\n", 0
 | 
			
		||||
| 
						 | 
				
			
			@ -722,7 +733,7 @@ bsock_do_not_rev_lookup_set(VALUE self, VALUE val)
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * BasicSocket class
 | 
			
		||||
 * BasicSocket is the super class for the all socket classes.
 | 
			
		||||
 */
 | 
			
		||||
void
 | 
			
		||||
Init_basicsocket(void)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -286,7 +286,7 @@ ip_s_getaddress(VALUE obj, VALUE host)
 | 
			
		|||
/*
 | 
			
		||||
 * Document-class: ::IPSocket < BasicSocket
 | 
			
		||||
 *
 | 
			
		||||
 * IPSocket class
 | 
			
		||||
 * IPSocket is the super class of TCPSocket and UDPSocket.
 | 
			
		||||
 */
 | 
			
		||||
void
 | 
			
		||||
Init_ipsocket(void)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -683,7 +683,7 @@ class Socket < BasicSocket
 | 
			
		|||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # creates UNIX server sockets on _path_
 | 
			
		||||
  # creates a UNIX server socket on _path_
 | 
			
		||||
  #
 | 
			
		||||
  # If no block given, it returns a listening socket.
 | 
			
		||||
  #
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -148,7 +148,7 @@ sockopt_data(VALUE self)
 | 
			
		|||
 *
 | 
			
		||||
 * Creates a new Socket::Option object which contains an int as data.
 | 
			
		||||
 *
 | 
			
		||||
 * The size and endian is dependent on the host. 
 | 
			
		||||
 * The size and endian is dependent on the platform. 
 | 
			
		||||
 *
 | 
			
		||||
 *   p Socket::Option.int(:INET, :SOCKET, :KEEPALIVE, 1)
 | 
			
		||||
 *   #=> #<Socket::Option: INET SOCKET KEEPALIVE 1>
 | 
			
		||||
| 
						 | 
				
			
			@ -169,7 +169,7 @@ sockopt_s_int(VALUE klass, VALUE vfamily, VALUE vlevel, VALUE voptname, VALUE vi
 | 
			
		|||
 *
 | 
			
		||||
 * Returns the data in _sockopt_ as an int.
 | 
			
		||||
 *
 | 
			
		||||
 * The size and endian is dependent on the host. 
 | 
			
		||||
 * The size and endian is dependent on the platform. 
 | 
			
		||||
 *
 | 
			
		||||
 *   sockopt = Socket::Option.int(:INET, :SOCKET, :KEEPALIVE, 1)
 | 
			
		||||
 *   p sockopt.int => 1
 | 
			
		||||
| 
						 | 
				
			
			@ -660,6 +660,10 @@ sockopt_unpack(VALUE self, VALUE template)
 | 
			
		|||
 | 
			
		||||
/*
 | 
			
		||||
 * Document-class: ::Socket::Option
 | 
			
		||||
 *
 | 
			
		||||
 * Socket::Option represents a socket option used by getsockopt and setsockopt
 | 
			
		||||
 * system call.
 | 
			
		||||
 * It contains socket family, protocol level, option name and option value.
 | 
			
		||||
 */
 | 
			
		||||
void
 | 
			
		||||
Init_sockopt(void)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -134,13 +134,13 @@ rsock_sock_s_socketpair(int argc, VALUE *argv, VALUE klass)
 | 
			
		|||
 | 
			
		||||
/*
 | 
			
		||||
 * call-seq:
 | 
			
		||||
 * 	socket.connect(server_sockaddr) => 0
 | 
			
		||||
 * 	socket.connect(remote_sockaddr) => 0
 | 
			
		||||
 * 
 | 
			
		||||
 * Requests a connection to be made on the given +server_sockaddr+. Returns 0 if
 | 
			
		||||
 * Requests a connection to be made on the given +remote_sockaddr+. Returns 0 if
 | 
			
		||||
 * successful, otherwise an exception is raised.
 | 
			
		||||
 *  
 | 
			
		||||
 * === Parameter
 | 
			
		||||
 * * +server_sockaddr+ - the +struct+ sockaddr contained in a string
 | 
			
		||||
 * * +remote_sockaddr+ - the +struct+ sockaddr contained in a string or Addrinfo object
 | 
			
		||||
 * 
 | 
			
		||||
 * === Example:
 | 
			
		||||
 * 	# Pull down Google's web page
 | 
			
		||||
| 
						 | 
				
			
			@ -263,14 +263,14 @@ sock_connect(VALUE sock, VALUE addr)
 | 
			
		|||
 | 
			
		||||
/*
 | 
			
		||||
 * call-seq:
 | 
			
		||||
 * 	socket.connect_nonblock(server_sockaddr) => 0
 | 
			
		||||
 * 	socket.connect_nonblock(remote_sockaddr) => 0
 | 
			
		||||
 * 
 | 
			
		||||
 * Requests a connection to be made on the given +server_sockaddr+ after
 | 
			
		||||
 * Requests a connection to be made on the given +remote_sockaddr+ after
 | 
			
		||||
 * O_NONBLOCK is set for the underlying file descriptor.
 | 
			
		||||
 * Returns 0 if successful, otherwise an exception is raised.
 | 
			
		||||
 *  
 | 
			
		||||
 * === Parameter
 | 
			
		||||
 * * +server_sockaddr+ - the +struct+ sockaddr contained in a string
 | 
			
		||||
 * * +remote_sockaddr+ - the +struct+ sockaddr contained in a string or Addrinfo object
 | 
			
		||||
 * 
 | 
			
		||||
 * === Example:
 | 
			
		||||
 * 	# Pull down Google's web page
 | 
			
		||||
| 
						 | 
				
			
			@ -325,15 +325,22 @@ sock_connect_nonblock(VALUE sock, VALUE addr)
 | 
			
		|||
 | 
			
		||||
/*
 | 
			
		||||
 * call-seq:
 | 
			
		||||
 * 	socket.bind(server_sockaddr) => 0
 | 
			
		||||
 * 	socket.bind(local_sockaddr) => 0
 | 
			
		||||
 * 
 | 
			
		||||
 * Binds to the given +struct+ sockaddr.
 | 
			
		||||
 * Binds to the given local address.
 | 
			
		||||
 * 
 | 
			
		||||
 * === Parameter
 | 
			
		||||
 * * +server_sockaddr+ - the +struct+ sockaddr contained in a string
 | 
			
		||||
 * * +local_sockaddr+ - the +struct+ sockaddr contained in a string or an Addrinfo object
 | 
			
		||||
 *
 | 
			
		||||
 * === Example
 | 
			
		||||
 * 	require 'socket'
 | 
			
		||||
 *
 | 
			
		||||
 * 	# use Addrinfo
 | 
			
		||||
 * 	socket = Socket.new(:INET, :STREAM, 0)
 | 
			
		||||
 * 	socket.bind(Addrinfo.tcp("127.0.0.1", 2222))
 | 
			
		||||
 * 	p socket.local_address #=> #<Addrinfo: 127.0.0.1:2222 TCP>
 | 
			
		||||
 *
 | 
			
		||||
 * 	# use struct sockaddr
 | 
			
		||||
 * 	include Socket::Constants
 | 
			
		||||
 * 	socket = Socket.new( AF_INET, SOCK_STREAM, 0 )
 | 
			
		||||
 * 	sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' )
 | 
			
		||||
| 
						 | 
				
			
			@ -507,11 +514,11 @@ rsock_sock_listen(VALUE sock, VALUE log)
 | 
			
		|||
 * 
 | 
			
		||||
 * Receives up to _maxlen_ bytes from +socket+. _flags_ is zero or more
 | 
			
		||||
 * of the +MSG_+ options. The first element of the results, _mesg_, is the data
 | 
			
		||||
 * received. The second element, _sender_addrinfo_, contains protocol-specific information
 | 
			
		||||
 * on the sender.
 | 
			
		||||
 * received. The second element, _sender_addrinfo_, contains protocol-specific
 | 
			
		||||
 * address information of the sender.
 | 
			
		||||
 * 
 | 
			
		||||
 * === Parameters
 | 
			
		||||
 * * +maxlen+ - the number of bytes to receive from the socket
 | 
			
		||||
 * * +maxlen+ - the maximum number of bytes to receive from the socket
 | 
			
		||||
 * * +flags+ - zero or more of the +MSG_+ options 
 | 
			
		||||
 * 
 | 
			
		||||
 * === Example
 | 
			
		||||
| 
						 | 
				
			
			@ -620,15 +627,15 @@ sock_recvfrom(int argc, VALUE *argv, VALUE sock)
 | 
			
		|||
 * O_NONBLOCK is set for the underlying file descriptor.
 | 
			
		||||
 * _flags_ is zero or more of the +MSG_+ options.
 | 
			
		||||
 * The first element of the results, _mesg_, is the data received.
 | 
			
		||||
 * The second element, _sender_addrinfo_, contains protocol-specific information
 | 
			
		||||
 * on the sender.
 | 
			
		||||
 * The second element, _sender_addrinfo_, contains protocol-specific address
 | 
			
		||||
 * information of the sender.
 | 
			
		||||
 *
 | 
			
		||||
 * When recvfrom(2) returns 0, Socket#recvfrom_nonblock returns
 | 
			
		||||
 * an empty string as data.
 | 
			
		||||
 * The meaning depends on the socket: EOF on TCP, empty packet on UDP, etc.
 | 
			
		||||
 * 
 | 
			
		||||
 * === Parameters
 | 
			
		||||
 * * +maxlen+ - the number of bytes to receive from the socket
 | 
			
		||||
 * * +maxlen+ - the maximum number of bytes to receive from the socket
 | 
			
		||||
 * * +flags+ - zero or more of the +MSG_+ options 
 | 
			
		||||
 * 
 | 
			
		||||
 * === Example
 | 
			
		||||
| 
						 | 
				
			
			@ -689,7 +696,7 @@ sock_recvfrom_nonblock(int argc, VALUE *argv, VALUE sock)
 | 
			
		|||
 *   serv = Socket.new(:INET, :STREAM, 0)
 | 
			
		||||
 *   serv.listen(5)
 | 
			
		||||
 *   c = Socket.new(:INET, :STREAM, 0)
 | 
			
		||||
 *   c.connect(serv.local_address)
 | 
			
		||||
 *   c.connect(serv.connect_address)
 | 
			
		||||
 *   p serv.accept #=> [#<Socket:fd 6>, #<Addrinfo: 127.0.0.1:48555 TCP>]
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
| 
						 | 
				
			
			@ -830,10 +837,10 @@ sock_sysaccept(VALUE sock)
 | 
			
		|||
 *
 | 
			
		||||
 * Returns the hostname.
 | 
			
		||||
 *
 | 
			
		||||
 * Note that it is not guaranteed to be able to convert to IP address using gethostbyname, getaddrinfo, etc.
 | 
			
		||||
 *
 | 
			
		||||
 *   p Socket.gethostname #=> "hal"
 | 
			
		||||
 *
 | 
			
		||||
 * Note that it is not guaranteed to be able to convert to IP address using gethostbyname, getaddrinfo, etc.
 | 
			
		||||
 * If you need local IP address, use Socket.ip_address_list.
 | 
			
		||||
 */
 | 
			
		||||
static VALUE
 | 
			
		||||
sock_gethostname(VALUE obj)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -131,7 +131,7 @@ tcp_sysaccept(VALUE sock)
 | 
			
		|||
/*
 | 
			
		||||
 * Document-class: ::TCPServer < TCPSocket
 | 
			
		||||
 *
 | 
			
		||||
 * TCPServer class
 | 
			
		||||
 * TCPServer represents a TCP/IP server socket.
 | 
			
		||||
 */
 | 
			
		||||
void
 | 
			
		||||
Init_tcpserver(void)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -58,7 +58,7 @@ tcp_s_gethostbyname(VALUE obj, VALUE host)
 | 
			
		|||
/*
 | 
			
		||||
 * Document-class: ::TCPSocket < IPSocket
 | 
			
		||||
 *
 | 
			
		||||
 * TCPSocket class
 | 
			
		||||
 * TCPSocket represents a TCP/IP client socket.
 | 
			
		||||
 */
 | 
			
		||||
void
 | 
			
		||||
Init_tcpsocket(void)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -249,7 +249,7 @@ udp_recvfrom_nonblock(int argc, VALUE *argv, VALUE sock)
 | 
			
		|||
/*
 | 
			
		||||
 * Document-class: ::UDPSocket < IPSocket
 | 
			
		||||
 *
 | 
			
		||||
 * UDPSocket class
 | 
			
		||||
 * UDPSocket represents a UDP/IP socket.
 | 
			
		||||
 */
 | 
			
		||||
void
 | 
			
		||||
Init_udpsocket(void)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -138,7 +138,7 @@ unix_sysaccept(VALUE sock)
 | 
			
		|||
/*
 | 
			
		||||
 * Document-class: ::UNIXServer < UNIXSocket
 | 
			
		||||
 *
 | 
			
		||||
 * UNIXServer class
 | 
			
		||||
 * UNIXServer represents a UNIX domain stream server socket.
 | 
			
		||||
 */
 | 
			
		||||
void
 | 
			
		||||
Init_unixserver(void)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -487,7 +487,7 @@ unix_s_socketpair(int argc, VALUE *argv, VALUE klass)
 | 
			
		|||
/*
 | 
			
		||||
 * Document-class: ::UNIXSocket < BasicSocket
 | 
			
		||||
 *
 | 
			
		||||
 * UNIXSocket class
 | 
			
		||||
 * UNIXSocket represents a UNIX domain stream client socket.
 | 
			
		||||
 */
 | 
			
		||||
void
 | 
			
		||||
Init_unixsocket(void)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue