From 12979424515344460afb12002ce07b670bf7cd6f Mon Sep 17 00:00:00 2001 From: drbrain Date: Mon, 15 Aug 2011 23:08:39 +0000 Subject: * 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 --- ext/socket/tcpsocket.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'ext/socket/tcpsocket.c') diff --git a/ext/socket/tcpsocket.c b/ext/socket/tcpsocket.c index 42d75d6015..7eb6fc7aa2 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); -- cgit v1.2.3