Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 5df549184235
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 5377122aecaa
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Aug 6, 2015

  1. Copy the full SHA
    b4facab View commit details
  2. enable pack_sockaddr_in to work when port is nil

    This change treats it as 0 per MRI Ruby
    reuben-sutton authored and kares committed Aug 6, 2015
    Copy the full SHA
    5377122 View commit details
Showing with 8 additions and 1 deletion.
  1. +5 −1 core/src/main/java/org/jruby/ext/socket/SocketUtils.java
  2. +3 −0 spec/ruby/library/socket/shared/pack_sockaddr.rb
6 changes: 5 additions & 1 deletion core/src/main/java/org/jruby/ext/socket/SocketUtils.java
Original file line number Diff line number Diff line change
@@ -129,9 +129,13 @@ public static IRubyObject getservbyname(ThreadContext context, IRubyObject[] arg
}

public static IRubyObject pack_sockaddr_in(ThreadContext context, IRubyObject port, IRubyObject host) {
int portNum = port instanceof RubyString ?
int portNum = 0;

if(!port.isNil()){
portNum = port instanceof RubyString ?
Integer.parseInt(port.convertToString().toString()) :
RubyNumeric.fix2int(port);
}

return Sockaddr.pack_sockaddr_in(
context,
3 changes: 3 additions & 0 deletions spec/ruby/library/socket/shared/pack_sockaddr.rb
Original file line number Diff line number Diff line change
@@ -13,6 +13,9 @@

sockaddr_in = Socket.pack_sockaddr_in '80', '127.0.0.1'
Socket.unpack_sockaddr_in(sockaddr_in).should == [80, '127.0.0.1']

sockaddr_in = Socket.pack_sockaddr_in nil, '127.0.0.1'
Socket.unpack_sockaddr_in(sockaddr_in).should == [0, '127.0.0.1']
end
end