ruby socket dgram example
Posted
by Bub Bradlee
on Stack Overflow
See other posts from Stack Overflow
or by Bub Bradlee
Published on 2010-04-27T22:56:08Z
Indexed on
2010/04/28
7:33 UTC
Read the original article
Hit count: 428
I'm trying to use unix sockets and SOCK_DGRAM in ruby, but am having a really hard time figuring out how to do it. So far, I've been trying things like this:
sock_path = 'test.socket'
s1 = Socket.new(Socket::AF_UNIX, Socket::SOCK_DGRAM, 0)
s1.bind(Socket.pack_sockaddr_un(sock_path))
s2 = Socket.new(Socket::AF_UNIX, Socket::SOCK_DGRAM, 0)
s2.bind(Socket.pack_sockaddr_un(sock_path))
s1.send("HELLO")
s2.recv(5) # should equal "HELLO"
Does anybody have experience with this?
© Stack Overflow or respective owner