Skip to content

Commit

Permalink
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions core/src/main/java/org/jruby/ext/socket/RubyUDPSocket.java
Original file line number Diff line number Diff line change
@@ -40,6 +40,7 @@
import java.net.SocketAddress;
import java.net.SocketException;
import java.net.MulticastSocket;
import java.net.SocketOption;
import java.net.StandardProtocolFamily;
import java.net.UnknownHostException;
import java.net.DatagramPacket;
@@ -48,6 +49,7 @@
import java.nio.channels.DatagramChannel;
import java.nio.channels.IllegalBlockingModeException;
import java.nio.channels.NotYetConnectedException;
import java.nio.channels.UnsupportedAddressTypeException;

import jnr.constants.platform.AddressFamily;
import jnr.netdb.Service;
@@ -123,6 +125,7 @@ public IRubyObject initialize(ThreadContext context, ProtocolFamily family) {
Ruby runtime = context.runtime;

try {
this.family = family;
DatagramChannel channel = DatagramChannel.open(family);
initSocket(newChannelFD(runtime, channel));
} catch (ConnectException e) {
@@ -188,6 +191,11 @@ else if (host instanceof RubyFixnum) {

return RubyFixnum.zero(runtime);
}
catch (UnsupportedAddressTypeException e) {
// This may not be the appropriate message for all such exceptions
ProtocolFamily family = this.family == null ? StandardProtocolFamily.INET : this.family;
throw SocketUtils.sockerr(runtime, "bind: unsupported address " + host.inspect() + " for protocol family " + family);
}
catch (UnknownHostException e) {
throw SocketUtils.sockerr(runtime, "bind: name or service not known");
}
@@ -630,6 +638,7 @@ private static IRubyObject doReceiveMulticast(RubyBasicSocket socket, final Ruby
}

private volatile Class<? extends InetAddress> explicitFamily;
private volatile ProtocolFamily family;

@Deprecated
public IRubyObject bind(IRubyObject host, IRubyObject port) {

0 comments on commit e15f74e

Please sign in to comment.