private static IRubyObject doReceiveMulticast(RubyBasicSocket socket, final Ruby runtime, final boolean non_block, int length, ReceiveTuple tuple) throws IOException { ByteBuffer recv = ByteBuffer.wrap(new byte[length]); SocketAddress address; DatagramChannel channel = socket.multicastStateManager.getMulticastSocket().getChannel(); address = channel.receive(recv); if (address == null) { if ( non_block ) return null; // :wait_readable or raise WaitReadable throw runtime.newErrnoEAGAINReadableError("multicast UDP does not support nonblocking"); } InetSocketAddress sender = (InetSocketAddress) address; // see JRUBY-4678 if (sender == null) { throw runtime.newErrnoECONNRESETError(); } recv.flip(); RubyString result = runtime.newString(new ByteList(recv.array(), recv.position(), recv.limit(), false)); if (tuple != null) { tuple.result = result; tuple.sender = sender; } return result; }
private static IRubyObject doReceiveMulticast(RubyBasicSocket socket, final Ruby runtime, final boolean non_block, int length, ReceiveTuple tuple) throws IOException { ByteBuffer recv = ByteBuffer.wrap(new byte[length]); SocketAddress address; DatagramChannel channel = socket.multicastStateManager.getMulticastSocket().getChannel(); address = channel.receive(recv); if (address == null) { if ( non_block ) return null; // :wait_readable or raise WaitReadable throw runtime.newErrnoEAGAINReadableError("multicast UDP does not support nonblocking"); } InetSocketAddress sender = (InetSocketAddress) address; // see JRUBY-4678 if (sender == null) { throw runtime.newErrnoECONNRESETError(); } recv.flip(); RubyString result = runtime.newString(new ByteList(recv.array(), recv.position(), recv.limit(), false)); if (tuple != null) { tuple.result = result; tuple.sender = sender; } return result; }
private IRubyObject doReceiveMulticast(Ruby runtime, int length, ReceiveTuple tuple) throws IOException { byte[] buf2 = new byte[length]; DatagramPacket recv = new DatagramPacket(buf2, buf2.length); MulticastSocket ms = this.multicastStateManager.getMulticastSocket(); try { ms.receive(recv); } catch (IllegalBlockingModeException ibme) { // MulticastSocket does not support nonblocking // TODO: Use Java 7 NIO.2 DatagramChannel to do multicast if (runtime.is1_9()) { throw runtime.newErrnoEAGAINReadableError("multicast UDP does not support nonblocking"); } else { throw runtime.newErrnoEAGAINError("multicast UDP does not support nonblocking"); } } InetSocketAddress sender = (InetSocketAddress) recv.getSocketAddress(); // see JRUBY-4678 if (sender == null) { throw runtime.newErrnoECONNRESETError(); } RubyString result = runtime.newString(new ByteList(recv.getData(), 0, recv.getLength())); if (tuple != null) { tuple.result = result; tuple.sender = sender; } return result; }
private IRubyObject doReceiveMulticast(Ruby runtime, int length, ReceiveTuple tuple) throws IOException { byte[] buf2 = new byte[length]; DatagramPacket recv = new DatagramPacket(buf2, buf2.length); MulticastSocket ms = this.multicastStateManager.getMulticastSocket(); try { ms.receive(recv); } catch (IllegalBlockingModeException ibme) { // MulticastSocket does not support nonblocking // TODO: Use Java 7 NIO.2 DatagramChannel to do multicast if (runtime.is1_9()) { throw runtime.newErrnoEAGAINReadableError("multicast UDP does not support nonblocking"); } else { throw runtime.newErrnoEAGAINError("multicast UDP does not support nonblocking"); } } InetSocketAddress sender = (InetSocketAddress) recv.getSocketAddress(); // see JRUBY-4678 if (sender == null) { throw runtime.newErrnoECONNRESETError(); } RubyString result = runtime.newString(new ByteList(recv.getData(), 0, recv.getLength())); if (tuple != null) { tuple.result = result; tuple.sender = sender; } return result; }
sendDP = new DatagramPacket(buf2, buf2.length, addr); multicastStateManager.rebindToPort(addr.getPort()); MulticastSocket ms = this.multicastStateManager.getMulticastSocket();
sendDP = new DatagramPacket(buf2, buf2.length, addr); multicastStateManager.rebindToPort(addr.getPort()); MulticastSocket ms = this.multicastStateManager.getMulticastSocket();
sendDP = new DatagramPacket(buf2, buf2.length, address, port); multicastStateManager.rebindToPort(port); MulticastSocket ms = this.multicastStateManager.getMulticastSocket();
sendDP = new DatagramPacket(buf2, buf2.length, address, port); multicastStateManager.rebindToPort(port); MulticastSocket ms = this.multicastStateManager.getMulticastSocket();