public static int sendto(int fd, ByteBuffer src, SockAddrUnix addr, int len) throws IOException { if (src == null) { throw new IllegalArgumentException("Source buffer cannot be null"); } int n; do { n = libsocket().sendto(fd, src, src.remaining(), 0, addr, len); } while (n < 0 && Errno.EINTR.equals(getLastError())); if (n > 0) { src.position(src.position() + n); } return n; }
public static int recvfrom(int fd, ByteBuffer dst, SockAddrUnix addr) throws IOException { if (dst == null) { throw new IllegalArgumentException("Destination buffer cannot be null"); } if (dst.isReadOnly()) { throw new IllegalArgumentException("Read-only buffer"); } IntByReference addrlen = (null == addr) ? null : new IntByReference(addr.getMaximumLength()); int n; do { n = libsocket().recvfrom(fd, dst, dst.remaining(), 0, addr, addrlen); } while (n < 0 && Errno.EINTR.equals(getLastError())); if (n > 0) { dst.position(dst.position() + n); } return n; } }