#424 √ resolved
Joel Scotkin

[BUG] UDPSocket bind throws ArgumentError

Reported by Joel Scotkin | March 19th, 2008 @ 08:39 AM | in 1.0 preview

The following snippet

------

require "socket"

server = UDPSocket.open

server.bind(nil, 9999)

------

throws a "wrong number of arguments (got 5, required 4) error

with a partial backtrace of

Socket::Foreign.pack_sockaddr_in at /usr/local/lib/rubinius/0.8/socket.rb:246

UDPSocket#bind at /usr/local/lib/rubinius/0.8/socket.rb:562

I'm running on Fedora 8 x86, tested using git from today (Mar 19).

Thanks!

Joel

Comments and changes to this ticket

  • Ben Hughes

    Ben Hughes April 5th, 2008 @ 10:35 PM

    Found a typo on line 541 in lib/socket.rb

    @host,to_s should be @host.to_s

    that fixes the two many arguments issue

    and leaves you with

    irb(main):001:0> require "socket"; s = UDPSocket.open; s.bind(nil, 9999)

    TypeError: Invalid type encountered converting to int: nil

    from FFI::Struct(Socket::Foreign::AddrInfo)#[]= at kernel/platform/ffi.rb:550

    from Socket::Foreign.pack_sockaddr_in at /home/ben/projects/opensource/rubinius/lib/socket.rb:273

    from UDPSocket#bind at /home/ben/projects/opensource/rubinius/lib/socket.rb:563

    from Object#irb_binding {} at (irb):1

    which comes from

    lib/socket.rb:249

    hints[:ai_socktype] = type

    which is because

    @type
    is nil in UDPSocket#bind

    now I don't actually understand what these things mean or what should be done in this context

  • Dirkjan Bussink

    Dirkjan Bussink April 6th, 2008 @ 10:48 AM

    • → State changed from “new” to “resolved”

    I've reworked UDPSocket#initialize and UDPSocket#bind, so it's a bit more sane. Closing this for now, UDPSocket is not complete, but that's another issue.

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Tags