Bugs item #8055, was opened at 2007-01-21 19:46
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=1698&aid=8055&group_id=426

Category: Documentation, ri, and rdoc
Group: 1.8.x
Status: Open
Resolution: None
Priority: 3
Submitted By: Marc Soda (marcantonio)
>Assigned to: Eric Hodel (drbrain)
Summary: Error in Socket sample code

Initial Comment:
In much of the sample code a read operation is performed on the wrong file descriptor.  This is from the sample in Socket.accept:

     # In one script, start this first
     require 'socket'
     include Socket::Constants
     socket = Socket.new( AF_INET, SOCK_STREAM, 0 )
     sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' )
     socket.bind( sockaddr )
     socket.listen( 5 )
     client, client_sockaddr = socket.accept
>>>  puts "The client said, '#{socket.readline.chomp}'"
     client.puts "Hello from script one!"
     socket.close

The highlighted line should read:

     puts "The client said, '#{client.readline.chomp}'"

This same error is in many of the examples.



----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=1698&aid=8055&group_id=426