From 4043565023531d173478c216e2a9cc6228f44a7e Mon Sep 17 00:00:00 2001 From: hsbt Date: Wed, 5 Oct 2016 03:57:32 +0000 Subject: * ext/socket/*.c: Add proper require for example to work. [fix GH-1378][ci skip] Patch by @schneems git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ ext/socket/ancdata.c | 2 ++ ext/socket/basicsocket.c | 2 ++ ext/socket/ipsocket.c | 2 ++ ext/socket/option.c | 2 ++ ext/socket/socket.c | 2 ++ ext/socket/udpsocket.c | 2 ++ ext/socket/unixserver.c | 2 ++ ext/socket/unixsocket.c | 2 ++ 9 files changed, 21 insertions(+) diff --git a/ChangeLog b/ChangeLog index ef167b1c55..3645fd3bc6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Oct 5 12:57:21 2016 Richard Schneeman + + * ext/socket/*.c: Add proper require for example to work. + [fix GH-1378][ci skip] Patch by @schneems + Wed Oct 5 11:47:19 2016 SHIBATA Hiroshi * io.c: Fixed equivalent ruby code with core implemention. diff --git a/ext/socket/ancdata.c b/ext/socket/ancdata.c index 02766ba5d2..f5451c9569 100644 --- a/ext/socket/ancdata.c +++ b/ext/socket/ancdata.c @@ -360,6 +360,8 @@ ancillary_timestamp(VALUE self) * * The size and endian is dependent on the host. * + * require 'socket' + * * p Socket::AncillaryData.int(:UNIX, :SOCKET, :RIGHTS, STDERR.fileno) * #=> # */ diff --git a/ext/socket/basicsocket.c b/ext/socket/basicsocket.c index 2d2b22e1a9..ee967c7b7a 100644 --- a/ext/socket/basicsocket.c +++ b/ext/socket/basicsocket.c @@ -565,6 +565,8 @@ rsock_bsock_send(int argc, VALUE *argv, VALUE sock) * * Gets the do_not_reverse_lookup flag of _basicsocket_. * + * require 'socket' + * * BasicSocket.do_not_reverse_lookup = false * TCPSocket.open("www.ruby-lang.org", 80) {|sock| * p sock.do_not_reverse_lookup #=> false diff --git a/ext/socket/ipsocket.c b/ext/socket/ipsocket.c index 9981fd43ad..dbf403b39a 100644 --- a/ext/socket/ipsocket.c +++ b/ext/socket/ipsocket.c @@ -303,6 +303,8 @@ ip_recvfrom(int argc, VALUE *argv, VALUE sock) * * Lookups the IP address of _host_. * + * require 'socket' + * * IPSocket.getaddress("localhost") #=> "127.0.0.1" * IPSocket.getaddress("ip6-localhost") #=> "::1" * diff --git a/ext/socket/option.c b/ext/socket/option.c index 4c75fe046d..bf3af171a2 100644 --- a/ext/socket/option.c +++ b/ext/socket/option.c @@ -272,6 +272,8 @@ sockopt_int(VALUE self) * Creates a new Socket::Option object which contains boolean as data. * Actually 0 or 1 as int is used. * + * require 'socket' + * * p Socket::Option.bool(:INET, :SOCKET, :KEEPALIVE, true) * #=> # * diff --git a/ext/socket/socket.c b/ext/socket/socket.c index 542cd02ed6..14e069bb8d 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -1955,6 +1955,8 @@ Init_socket(void) * * Let's create an internet socket using the IPv4 protocol in a C-like manner: * + * require 'socket' + * * s = Socket.new Socket::AF_INET, Socket::SOCK_STREAM * s.connect Socket.pack_sockaddr_in(80, 'example.com') * diff --git a/ext/socket/udpsocket.c b/ext/socket/udpsocket.c index 7b7b34f04d..c2e273c2a3 100644 --- a/ext/socket/udpsocket.c +++ b/ext/socket/udpsocket.c @@ -19,6 +19,8 @@ * _address_family_ should be an integer, a string or a symbol: * Socket::AF_INET, "AF_INET", :INET, etc. * + * require 'socket' + * * UDPSocket.new #=> # * UDPSocket.new(Socket::AF_INET6) #=> # * diff --git a/ext/socket/unixserver.c b/ext/socket/unixserver.c index 799dcffb00..b1f2a38547 100644 --- a/ext/socket/unixserver.c +++ b/ext/socket/unixserver.c @@ -17,6 +17,8 @@ * * Creates a new UNIX server socket bound to _path_. * + * require 'socket' + * * serv = UNIXServer.new("/tmp/sock") * s = serv.accept * p s.read diff --git a/ext/socket/unixsocket.c b/ext/socket/unixsocket.c index d1cf1e2b2a..5a44b552f8 100644 --- a/ext/socket/unixsocket.c +++ b/ext/socket/unixsocket.c @@ -93,6 +93,8 @@ rsock_init_unixsock(VALUE sock, VALUE path, int server) * * Creates a new UNIX client socket connected to _path_. * + * require 'socket' + * * s = UNIXSocket.new("/tmp/sock") * s.send "hello", 0 * -- cgit v1.2.3