Skip to content

Commit

Permalink
Fixes for BasicSocket#getpeername. Passes rubysl-socket.
Browse files Browse the repository at this point in the history
headius committed Mar 11, 2016
1 parent db72d34 commit c3323ab
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions core/src/main/java/org/jruby/ext/socket/RubyBasicSocket.java
Original file line number Diff line number Diff line change
@@ -339,11 +339,11 @@ public IRubyObject getpeername(ThreadContext context) {

InetSocketAddress sock = getInetRemoteSocket();

if (sock != null) return runtime.newString(sock.getHostName());
if (sock != null) return Sockaddr.pack_sockaddr_in(context, sock);

UnixSocketAddress unix = getUnixRemoteSocket();

return runtime.newString(unix.path());
return Sockaddr.pack_sockaddr_un(context, unix.path());
}

@JRubyMethod(name = "getpeereid", notImplemented = true)
@@ -580,7 +580,11 @@ protected SocketAddress getSocketAddress() {
protected SocketAddress getRemoteSocket() {
Channel channel = getOpenChannel();

return SocketType.forChannel(channel).getRemoteSocketAddress(channel);
SocketAddress address = SocketType.forChannel(channel).getRemoteSocketAddress(channel);

if (address == null) throw getRuntime().newErrnoENOTCONNError();

return address;
}

protected IRubyObject getSocknameCommon(ThreadContext context, String caller) {

0 comments on commit c3323ab

Please sign in to comment.