aboutsummaryrefslogtreecommitdiffstats
path: root/ext
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-03-09 09:29:52 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-03-09 09:29:52 +0000
commitf43cae2b057622e6812e370f2c7cb3efa06f6665 (patch)
treeca48f13383a026a57bb50ae9e0e3751154ff0420 /ext
parent9ef561b6e09a6d5768617e20db4d985ca34260e9 (diff)
downloadruby-f43cae2b057622e6812e370f2c7cb3efa06f6665.tar.gz
* parse.y (gettable_gen): warns if VCALL name is used as
out-of-scope block local variable. [EXPERIMENTAL] * parse.y (opt_bv_decl): add explicit block local variable declaration. raises error for name conflicts. [EXPERIMENTAL] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/socket/socket.c85
-rw-r--r--ext/tk/sample/demos-en/floor.rb4
-rw-r--r--ext/tk/sample/demos-en/floor2.rb4
-rw-r--r--ext/tk/sample/demos-jp/floor.rb4
-rw-r--r--ext/tk/sample/demos-jp/floor2.rb4
5 files changed, 93 insertions, 8 deletions
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index 230966bae4..9383580bdf 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -271,6 +271,51 @@ bsock_close_write(sock)
return Qnil;
}
+/*
+ * Document-method: setsockopt
+ * call-seq: setsockopt(level, optname, optval)
+ *
+ * Sets a socket option. These are protocol and system specific, see your
+ * local sytem documentation for details.
+ *
+ * === Parameters
+ * * +level+ is an integer, usually one of the SOL_ constants such as
+ * Socket::SOL_SOCKET, or a protocol level.
+ * * +optname+ is an integer, usually one of the SO_ constants, such
+ * as Socket::SO_REUSEADDR.
+ * * +optval+ is the value of the option, it is passed to the underlying
+ * setsockopt() as a pointer to a certain number of bytes. How this is
+ * done depends on the type:
+ * - Fixnum: value is assigned to an int, and a pointer to the int is
+ * passed, with length of sizeof(int).
+ * - true or false: 1 or 0 (respectively) is assigned to an int, and the
+ * int is passed as for a Fixnum. Note that +false+ must be passed,
+ * not +nil+.
+ * - String: the string's data and length is passed to the socket.
+ *
+ * === Examples
+ *
+ * Some socket options are integers with boolean values, in this case
+ * #setsockopt could be called like this:
+ * sock.setsockopt(Socket::SOL_SOCKET,Socket::SO_REUSEADDR, true)
+ *
+ * Some socket options are integers with numeric values, in this case
+ * #setsockopt could be called like this:
+ * sock.setsockopt(Socket::IPPROTO_IP, Socket::IP_TTL, 255)
+ *
+ * Option values may be structs. Passing them can be complex as it involves
+ * examining your system headers to determine the correct definition. An
+ * example is an +ip_mreq+, which may be defined in your system headers as:
+ * struct ip_mreq {
+ * struct in_addr imr_multiaddr;
+ * struct in_addr imr_interface;
+ * };
+ *
+ * In this case #setsockopt could be called like this:
+ * optval = IPAddr.new("224.0.0.251") + Socket::INADDR_ANY
+ * sock.setsockopt(Socket::IPPROTO_IP, Socket::IP_ADD_MEMBERSHIP, optval)
+ *
+*/
static VALUE
bsock_setsockopt(sock, lev, optname, val)
VALUE sock, lev, optname, val;
@@ -311,6 +356,46 @@ bsock_setsockopt(sock, lev, optname, val)
return INT2FIX(0);
}
+/*
+ * Document-method: getsockopt
+ * call-seq: getsockopt(level, optname)
+ *
+ * Gets a socket option. These are protocol and system specific, see your
+ * local sytem documentation for details. The option is returned as
+ * a String with the data being the binary value of the socket option.
+ *
+ * === Parameters
+ * * +level+ is an integer, usually one of the SOL_ constants such as
+ * Socket::SOL_SOCKET, or a protocol level.
+ * * +optname+ is an integer, usually one of the SO_ constants, such
+ * as Socket::SO_REUSEADDR.
+ *
+ * === Examples
+ *
+ * Some socket options are integers with boolean values, in this case
+ * #getsockopt could be called like this:
+ * optval = sock.getsockopt(Socket::SOL_SOCKET,Socket::SO_REUSEADDR)
+ * optval = optval.unpack "i"
+ * reuseaddr = optval[0] == 0 ? false : true
+ *
+ * Some socket options are integers with numeric values, in this case
+ * #getsockopt could be called like this:
+ * optval = sock.getsockopt(Socket::IPPROTO_IP, Socket::IP_TTL)
+ * ipttl = optval.unpack("i")[0]
+ *
+ * Option values may be structs. Decoding them can be complex as it involves
+ * examining your system headers to determine the correct definition. An
+ * example is a +struct linger+, which may be defined in your system headers
+ * as:
+ * struct linger {
+ * int l_onoff;
+ * int l_linger;
+ * };
+ *
+ * In this case #getsockopt could be called like this:
+ * optval = sock.getsockopt(Socket::SOL_SOCKET, Socket::SO_LINGER)
+ * onoff, linger = optval.unpack "ii"
+*/
static VALUE
bsock_getsockopt(sock, lev, optname)
VALUE sock, lev, optname;
diff --git a/ext/tk/sample/demos-en/floor.rb b/ext/tk/sample/demos-en/floor.rb
index 15c56a154e..9c95770d43 100644
--- a/ext/tk/sample/demos-en/floor.rb
+++ b/ext/tk/sample/demos-en/floor.rb
@@ -1667,8 +1667,8 @@ else
pack('expand'=>'yes', 'fill'=>'both', 'padx'=>1, 'pady'=>1)
- v.command(proc{|*args| c.yview(*args)})
- h.command(proc{|*args| c.xview(*args)})
+ v.command(proc{|*args| f.yview(*args)})
+ h.command(proc{|*args| f.xview(*args)})
}
end
diff --git a/ext/tk/sample/demos-en/floor2.rb b/ext/tk/sample/demos-en/floor2.rb
index ab8659a628..513e02aaaa 100644
--- a/ext/tk/sample/demos-en/floor2.rb
+++ b/ext/tk/sample/demos-en/floor2.rb
@@ -1667,8 +1667,8 @@ else
pack('expand'=>'yes', 'fill'=>'both', 'padx'=>1, 'pady'=>1)
- v.command(proc{|*args| c.yview(*args)})
- h.command(proc{|*args| c.xview(*args)})
+ v.command(proc{|*args| f.yview(*args)})
+ h.command(proc{|*args| f.xview(*args)})
}
end
diff --git a/ext/tk/sample/demos-jp/floor.rb b/ext/tk/sample/demos-jp/floor.rb
index 517600de92..d258bb6486 100644
--- a/ext/tk/sample/demos-jp/floor.rb
+++ b/ext/tk/sample/demos-jp/floor.rb
@@ -1664,8 +1664,8 @@ else
pack('expand'=>'yes', 'fill'=>'both', 'padx'=>1, 'pady'=>1)
- v.command(proc{|*args| c.yview(*args)})
- h.command(proc{|*args| c.xview(*args)})
+ v.command(proc{|*args| f.yview(*args)})
+ h.command(proc{|*args| f.xview(*args)})
}
end
diff --git a/ext/tk/sample/demos-jp/floor2.rb b/ext/tk/sample/demos-jp/floor2.rb
index fcf208b61f..9812240dce 100644
--- a/ext/tk/sample/demos-jp/floor2.rb
+++ b/ext/tk/sample/demos-jp/floor2.rb
@@ -1664,8 +1664,8 @@ else
pack('expand'=>'yes', 'fill'=>'both', 'padx'=>1, 'pady'=>1)
- v.command(proc{|*args| c.yview(*args)})
- h.command(proc{|*args| c.xview(*args)})
+ v.command(proc{|*args| f.yview(*args)})
+ h.command(proc{|*args| f.xview(*args)})
}
end