celluloid / celluloid-io

UNMAINTAINED: See celluloid/celluloid#779 - Evented sockets for Celluloid actors
https://celluloid.io
MIT License
879 stars 93 forks source link

[Feature request] Access to socket option within UDPSocket and TCPSocket #161

Closed nagius closed 8 years ago

nagius commented 8 years ago

It would be nice to be able to access to setsockopt() on the socket. For example, this is necessary for broadcasting:

@socket = Celluloid::IO::UDPSocket.new
@socket.bind(host, port)
@socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_BROADCAST, true)

This doesn't work and raise an exception : NoMethodError: undefined method `setsockopt'

nagius commented 8 years ago

This monkey-patch do the trick :

module Celluloid
    module IO
        class UDPSocket
           def_delegators :@socket, :setsockopt
        end
    end
end
HoneyryderChuck commented 8 years ago

@nagius Here is how it's done: https://github.com/celluloid/celluloid-io/blob/master/lib/celluloid/io/udp_socket.rb#L6 . Care to pull request?

nagius commented 8 years ago

Hi,

Back from holidays, I saw that it's now working with version 0.17.3 (6bdde40fd68401fcf2d3b0b34f3a6bcf43e299ec)

Thanks !