ruby-changes:15135
From: akr <ko1@a...>
Date: Mon, 22 Mar 2010 18:46:11 +0900 (JST)
Subject: [ruby-changes:15135] Ruby:r27012 (trunk): update doc.
akr 2010-03-22 18:45:57 +0900 (Mon, 22 Mar 2010) New Revision: 27012 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=27012 Log: update doc. Modified files: trunk/ext/socket/ancdata.c trunk/ext/socket/basicsocket.c trunk/ext/socket/ipsocket.c trunk/ext/socket/lib/socket.rb trunk/ext/socket/option.c trunk/ext/socket/socket.c trunk/ext/socket/tcpserver.c trunk/ext/socket/tcpsocket.c trunk/ext/socket/udpsocket.c trunk/ext/socket/unixserver.c trunk/ext/socket/unixsocket.c Index: ext/socket/tcpsocket.c =================================================================== --- ext/socket/tcpsocket.c (revision 27011) +++ ext/socket/tcpsocket.c (revision 27012) @@ -58,7 +58,7 @@ /* * Document-class: ::TCPSocket < IPSocket * - * TCPSocket class + * TCPSocket represents a TCP/IP client socket. */ void Init_tcpsocket(void) Index: ext/socket/udpsocket.c =================================================================== --- ext/socket/udpsocket.c (revision 27011) +++ ext/socket/udpsocket.c (revision 27012) @@ -249,7 +249,7 @@ /* * Document-class: ::UDPSocket < IPSocket * - * UDPSocket class + * UDPSocket represents a UDP/IP socket. */ void Init_udpsocket(void) Index: ext/socket/option.c =================================================================== --- ext/socket/option.c (revision 27011) +++ ext/socket/option.c (revision 27012) @@ -148,7 +148,7 @@ * * 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 @@ * * 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 @@ /* * 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) Index: ext/socket/unixserver.c =================================================================== --- ext/socket/unixserver.c (revision 27011) +++ ext/socket/unixserver.c (revision 27012) @@ -138,7 +138,7 @@ /* * Document-class: ::UNIXServer < UNIXSocket * - * UNIXServer class + * UNIXServer represents a UNIX domain stream server socket. */ void Init_unixserver(void) Index: ext/socket/tcpserver.c =================================================================== --- ext/socket/tcpserver.c (revision 27011) +++ ext/socket/tcpserver.c (revision 27012) @@ -131,7 +131,7 @@ /* * Document-class: ::TCPServer < TCPSocket * - * TCPServer class + * TCPServer represents a TCP/IP server socket. */ void Init_tcpserver(void) Index: ext/socket/ipsocket.c =================================================================== --- ext/socket/ipsocket.c (revision 27011) +++ ext/socket/ipsocket.c (revision 27012) @@ -286,7 +286,7 @@ /* * Document-class: ::IPSocket < BasicSocket * - * IPSocket class + * IPSocket is the super class of TCPSocket and UDPSocket. */ void Init_ipsocket(void) Index: ext/socket/lib/socket.rb =================================================================== --- ext/socket/lib/socket.rb (revision 27011) +++ ext/socket/lib/socket.rb (revision 27012) @@ -683,7 +683,7 @@ end end - # creates UNIX server sockets on _path_ + # creates a UNIX server socket on _path_ # # If no block given, it returns a listening socket. # Index: ext/socket/socket.c =================================================================== --- ext/socket/socket.c (revision 27011) +++ ext/socket/socket.c (revision 27012) @@ -134,13 +134,13 @@ /* * 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 @@ /* * 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 @@ /* * 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 @@ * * 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 @@ * 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 @@ * 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 @@ * * 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) Index: ext/socket/basicsocket.c =================================================================== --- ext/socket/basicsocket.c (revision 27011) +++ ext/socket/basicsocket.c (revision 27012) @@ -89,7 +89,7 @@ * 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 @@ * 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 @@ * }; * * 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 @@ * * 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 @@ * 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 @@ * 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 @@ * * 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 @@ * * 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 @@ /* * 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 @@ * * _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 @@ } /* - * BasicSocket class + * BasicSocket is the super class for the all socket classes. */ void Init_basicsocket(void) Index: ext/socket/ancdata.c =================================================================== --- ext/socket/ancdata.c (revision 27011) +++ ext/socket/ancdata.c (revision 27012) @@ -1769,6 +1769,10 @@ /* * 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) Index: ext/socket/unixsocket.c =================================================================== --- ext/socket/unixsocket.c (revision 27011) +++ ext/socket/unixsocket.c (revision 27012) @@ -487,7 +487,7 @@ /* * Document-class: ::UNIXSocket < BasicSocket * - * UNIXSocket class + * UNIXSocket represents a UNIX domain stream client socket. */ void Init_unixsocket(void) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/