Roeland Moors
12/26/2004 9:45:00 PM
I'm trying to create something that writes to a socket.
This is my code:
require 'socket'
sock = Socket.new(Socket::PF_UNIX, Socket::SOCK_STREAM, 0)
sock.connect(Socket::sockaddr_un(device))
sock.puts('VERSION')
sock.close
This works sometimes, but sometimes it don't and then I get this
error:
test.rb:4:in `write': Broken pipe (Errno::EPIPE)
from test.rb:4:in `puts'
from test.rb:4
I can get it to work always if i put 'sleep 0.1' after
connecting. But way do I have to do this. Is there a better
method?
--
Roeland