summaryrefslogtreecommitdiff
path: root/ext/socket/tcpsocket.c
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-08-15 23:08:39 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-08-15 23:08:39 +0000
commit12979424515344460afb12002ce07b670bf7cd6f (patch)
tree2d85f664a0fb708e459a30c56738487948ced8f9 /ext/socket/tcpsocket.c
parent39e112f89a4e7471bb95ec516b05c75ac6df5aa9 (diff)
* ext/socket: Make Socket documentation appear. Add documentation for
Socket, TCPServer, SOCKSSocket. Patch by Sylvain Daubert. [Ruby 1.9 - Feature #5182] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32977 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket/tcpsocket.c')
-rw-r--r--ext/socket/tcpsocket.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/ext/socket/tcpsocket.c b/ext/socket/tcpsocket.c
index 42d75d6..7eb6fc7 100644
--- a/ext/socket/tcpsocket.c
+++ b/ext/socket/tcpsocket.c
@@ -55,14 +55,27 @@ tcp_s_gethostbyname(VALUE obj, VALUE host)
tcp_sockaddr);
}
-/*
- * Document-class: ::TCPSocket < IPSocket
- *
- * TCPSocket represents a TCP/IP client socket.
- */
void
rsock_init_tcpsocket(void)
{
+ /*
+ * Document-class: TCPSocket < IPSocket
+ *
+ * TCPSocket represents a TCP/IP client socket.
+ *
+ * A simple client may look like:
+ *
+ * require 'socket'
+ *
+ * s = TCPSocket.new 'localhost', 2000
+ *
+ * while line = s.gets # Read lines from socket
+ * puts line # and print them
+ * end
+ *
+ * s.close # close socket when done
+ *
+ */
rb_cTCPSocket = rb_define_class("TCPSocket", rb_cIPSocket);
rb_define_singleton_method(rb_cTCPSocket, "gethostbyname", tcp_s_gethostbyname, 1);
rb_define_method(rb_cTCPSocket, "initialize", tcp_init, -1);