In article <m21yurp0ym.fsf / zip.local.thomases.com>,
  Dave Thomas <Dave / PragmaticProgrammer.com> wrote:

> 2. Is there an existing file /tmp/sample that would stop the pipe from
>    being created.
>
The fact looks like this.  The program failed on its way because of my
typing error, but had already created /tmp/sample, and the correct
program never made it. It is better to add
      if FileTest.exist?($path)
         File.delete($path)  end
after the line $path = "temp/sample."

For AF_INET, we must give port numbers and IP addresses in place of the
file name.  Also, I think we must use something called struct sockaddr,
which corresponds to GNU C's struct sockaddr_in in this case.  But how?
Examples for a stand-alone computer seem something like the following.
Would anyone kindly supply correct ones?

#serverIN.rb
require 'socket'
sockaddr = "AF_INET, 9600, 127.0.0.1"
sock = Socket.open("AF_INET", "SOCK_STREAM", 0)
sock.bind(sockaddr)
while true
  s1 = sock.accept
  p s1.recvfrom(124)
  sock.close
end

#clientIN.rb
require 'socket'
sockaddr = "AF_INET, 9600, 127.0.0.1"
client = Socket.open("AF_INET", "SOCK_STREAM", 0)
client.bind(sockaddr)
client.send("hello", 0)
client.close


Sent via Deja.com
http://www.deja.com/