diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-03-22 09:45:57 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-03-22 09:45:57 +0000 |
commit | 652484598d802cd808b4b1fe4bef263b53e3119c (patch) | |
tree | 71e81335b64b61296a9d1eb4c1197c997b713e30 /ext/socket/socket.c | |
parent | 0edceaa7c733b35b48dcad02c0303625ae73e38c (diff) |
update doc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27012 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket/socket.c')
-rw-r--r-- | ext/socket/socket.c | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/ext/socket/socket.c b/ext/socket/socket.c index 1b026a6741..66dd5d9c20 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -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) |