/** * For PlainSocketOutputStream. */ private void write(byte[] buffer, int offset, int byteCount) throws IOException { Arrays.checkOffsetAndCount(buffer.length, offset, byteCount); if (streaming) { while (byteCount > 0) { int bytesWritten = IoBridge.sendto(fd, buffer, offset, byteCount, 0, null, 0); byteCount -= bytesWritten; offset += bytesWritten; } } else { // Unlike writes to a streaming socket, writes to a datagram // socket are all-or-nothing, so we don't need a loop here. // http://code.google.com/p/android/issues/detail?id=15304 // RoboVM note: The original code passed this.address here as // destination address. However, on Darwin sendto() fails with // EINVAL if called with a non-null destination address for an // already connected socket (see issue #76). Non-streaming Sockets // are always connected in the constructor so it should be safe to // pass null here instead. IoBridge.sendto(fd, buffer, offset, byteCount, 0, null, port); } } }
@Override public void send(DatagramPacket packet) throws IOException { int port = isNativeConnected ? 0 : packet.getPort(); InetAddress address = isNativeConnected ? null : packet.getAddress(); IoBridge.sendto(fd, packet.getData(), packet.getOffset(), packet.getLength(), 0, address, port); }
private int writeImpl(ByteBuffer buf) throws IOException { synchronized (writeLock) { int result = 0; try { begin(); result = IoBridge.sendto(fd, buf, 0, null, 0); } finally { end(result > 0); } return result; } }
@Override public int send(ByteBuffer source, SocketAddress socketAddress) throws IOException { checkNotNull(source); checkOpen(); InetSocketAddress isa = (InetSocketAddress) socketAddress; if (isa.getAddress() == null) { throw new IOException(); } if (isConnected() && !connectAddress.equals(isa)) { throw new IllegalArgumentException("Connected to " + connectAddress + ", not " + socketAddress); } synchronized (writeLock) { int sendCount = 0; try { begin(); int oldPosition = source.position(); sendCount = IoBridge.sendto(fd, source, 0, isa.getAddress(), isa.getPort()); if (sendCount > 0) { source.position(oldPosition + sendCount); } isBound = true; } finally { end(sendCount >= 0); } return sendCount; } }
private int writeImpl(ByteBuffer src) throws IOException { synchronized (writeLock) { if (!src.hasRemaining()) { return 0; } int writeCount = 0; try { if (isBlocking()) { begin(); } writeCount = IoBridge.sendto(fd, src, 0, null, 0); if (writeCount > 0) { src.position(src.position() + writeCount); } } finally { if (isBlocking()) { end(writeCount >= 0); } } return writeCount; } }
/** * For PlainSocketOutputStream. */ private void write(byte[] buffer, int offset, int byteCount) throws IOException { Arrays.checkOffsetAndCount(buffer.length, offset, byteCount); if (streaming) { while (byteCount > 0) { int bytesWritten = IoBridge.sendto(fd, buffer, offset, byteCount, 0, null, 0); byteCount -= bytesWritten; offset += bytesWritten; } } else { // Unlike writes to a streaming socket, writes to a datagram // socket are all-or-nothing, so we don't need a loop here. // http://code.google.com/p/android/issues/detail?id=15304 // RoboVM note: The original code passed this.address here as // destination address. However, on Darwin sendto() fails with // EINVAL if called with a non-null destination address for an // already connected socket (see issue #76). Non-streaming Sockets // are always connected in the constructor so it should be safe to // pass null here instead. IoBridge.sendto(fd, buffer, offset, byteCount, 0, null, port); } } }
@Override public void send(DatagramPacket packet) throws IOException { int port = isNativeConnected ? 0 : packet.getPort(); InetAddress address = isNativeConnected ? null : packet.getAddress(); IoBridge.sendto(fd, packet.getData(), packet.getOffset(), packet.getLength(), 0, address, port); }
@Override public void send(DatagramPacket packet) throws IOException { int port = isNativeConnected ? 0 : packet.getPort(); InetAddress address = isNativeConnected ? null : packet.getAddress(); IoBridge.sendto(fd, packet.getData(), packet.getOffset(), packet.getLength(), 0, address, port); }
@Override public void send(DatagramPacket packet) throws IOException { int port = isNativeConnected ? 0 : packet.getPort(); InetAddress address = isNativeConnected ? null : packet.getAddress(); IoBridge.sendto(fd, packet.getData(), packet.getOffset(), packet.getLength(), 0, address, port); }
@Override public void send(DatagramPacket packet) throws IOException { int port = isNativeConnected ? 0 : packet.getPort(); InetAddress address = isNativeConnected ? null : packet.getAddress(); IoBridge.sendto(fd, packet.getData(), packet.getOffset(), packet.getLength(), 0, address, port); }
@Override public void send(DatagramPacket packet) throws IOException { int port = isNativeConnected ? 0 : packet.getPort(); InetAddress address = isNativeConnected ? null : packet.getAddress(); IoBridge.sendto(fd, packet.getData(), packet.getOffset(), packet.getLength(), 0, address, port); }
@Override public void send(DatagramPacket packet) throws IOException { int port = isNativeConnected ? 0 : packet.getPort(); InetAddress address = isNativeConnected ? null : packet.getAddress(); IoBridge.sendto(fd, packet.getData(), packet.getOffset(), packet.getLength(), 0, address, port); }
private int writeImpl(ByteBuffer buf) throws IOException { synchronized (writeLock) { int result = 0; try { begin(); result = IoBridge.sendto(fd, buf, 0, null, 0); } finally { end(result > 0); } return result; } }
private int writeImpl(ByteBuffer buf) throws IOException { synchronized (writeLock) { int result = 0; try { begin(); result = IoBridge.sendto(fd, buf, 0, null, 0); } finally { end(result > 0); } return result; } }
private int writeImpl(ByteBuffer buf) throws IOException { synchronized (writeLock) { int result = 0; try { begin(); result = IoBridge.sendto(fd, buf, 0, null, 0); } finally { end(result > 0); } return result; } }
private int writeImpl(ByteBuffer buf) throws IOException { synchronized (writeLock) { int result = 0; try { begin(); result = IoBridge.sendto(fd, buf, 0, null, 0); } finally { end(result > 0); } return result; } }
private int writeImpl(ByteBuffer buf) throws IOException { synchronized (writeLock) { int result = 0; try { begin(); result = IoBridge.sendto(fd, buf, 0, null, 0); } finally { end(result > 0); } return result; } }
private int writeImpl(ByteBuffer buf) throws IOException { synchronized (writeLock) { int result = 0; try { begin(); result = IoBridge.sendto(fd, buf, 0, null, 0); } finally { end(result > 0); } return result; } }
private int writeImpl(ByteBuffer src) throws IOException { synchronized (writeLock) { if (!src.hasRemaining()) { return 0; } int writeCount = 0; try { if (isBlocking()) { begin(); } writeCount = IoBridge.sendto(fd, src, 0, null, 0); if (writeCount > 0) { src.position(src.position() + writeCount); } } finally { if (isBlocking()) { end(writeCount >= 0); } } return writeCount; } }
private int writeImpl(ByteBuffer src) throws IOException { synchronized (writeLock) { if (!src.hasRemaining()) { return 0; } int writeCount = 0; try { if (isBlocking()) { begin(); } writeCount = IoBridge.sendto(fd, src, 0, null, 0); if (writeCount > 0) { src.position(src.position() + writeCount); } } finally { if (isBlocking()) { end(writeCount >= 0); } } return writeCount; } }