All Superinterfaces:
com.sun.jna.platform.unix.LibCAPI, com.sun.jna.Library, com.sun.jna.platform.unix.Reboot, com.sun.jna.platform.unix.Resource

interface UnixSockets extends com.sun.jna.platform.unix.LibCAPI, com.sun.jna.Library
Low-level Unix/Linux JNA socket API.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface com.sun.jna.platform.unix.LibCAPI

    com.sun.jna.platform.unix.LibCAPI.size_t, com.sun.jna.platform.unix.LibCAPI.ssize_t

    Nested classes/interfaces inherited from interface com.sun.jna.Library

    com.sun.jna.Library.Handler

    Nested classes/interfaces inherited from interface com.sun.jna.platform.unix.Resource

    com.sun.jna.platform.unix.Resource.Rlimit
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Command to set the close-on-exec flag on a file descriptor via fcntl(int, int, int).
    static final int
    Specifies that a file descriptor shall not be inherited by child processes.
    static final String
    Library to load.

    Fields inherited from interface com.sun.jna.platform.unix.LibCAPI

    HOST_NAME_MAX

    Fields inherited from interface com.sun.jna.Library

    OPTION_ALLOW_OBJECTS, OPTION_CALLING_CONVENTION, OPTION_CLASSLOADER, OPTION_FUNCTION_MAPPER, OPTION_INVOCATION_MAPPER, OPTION_OPEN_FLAGS, OPTION_STRING_ENCODING, OPTION_STRUCTURE_ALIGNMENT, OPTION_SYMBOL_PROVIDER, OPTION_TYPE_MAPPER

    Fields inherited from interface com.sun.jna.platform.unix.Reboot

    RB_AUTOBOOT, RB_DISABLE_CAD, RB_ENABLE_CAD, RB_HALT_SYSTEM, RB_KEXEC, RB_POWER_OFF, RB_SW_SUSPEND

    Fields inherited from interface com.sun.jna.platform.unix.Resource

    RLIMIT_AS, RLIMIT_CORE, RLIMIT_CPU, RLIMIT_DATA, RLIMIT_FSIZE, RLIMIT_LOCKS, RLIMIT_MEMLOCK, RLIMIT_MSGQUEUE, RLIMIT_NICE, RLIMIT_NLIMITS, RLIMIT_NOFILE, RLIMIT_NPROC, RLIMIT_RSS, RLIMIT_RTPRIO, RLIMIT_RTTIME, RLIMIT_SIGPENDING, RLIMIT_STACK
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    connect(int fd, Sockets.SockAddr addr, int addrLen)
    Connects a file descriptor, which must refer to a socket, to a Sockets.SockAddr.
    int
    fcntl(int fd, int command, int flag)
    Simple binding to fcntl; used to set the FD_CLOEXEC flag.
    com.sun.jna.platform.unix.LibCAPI.ssize_t
    read(int fd, byte[] buf, com.sun.jna.platform.unix.LibCAPI.size_t bufLen)
    Read data from a file descriptor.
    int
    socket(int domain, int type, int protocol)
    Creates a socket and returns a file descriptor for it.
    com.sun.jna.platform.unix.LibCAPI.ssize_t
    write(int fd, byte[] data, com.sun.jna.platform.unix.LibCAPI.size_t dataLen)
    Write data to a file descriptor.

    Methods inherited from interface com.sun.jna.platform.unix.LibCAPI

    close, getdomainname, getegid, getenv, geteuid, getgid, gethostname, getloadavg, getuid, msync, munmap, setdomainname, setegid, setenv, seteuid, setgid, sethostname, setuid, unsetenv

    Methods inherited from interface com.sun.jna.platform.unix.Reboot

    reboot

    Methods inherited from interface com.sun.jna.platform.unix.Resource

    getrlimit, setrlimit
  • Field Details

  • Method Details

    • socket

      int socket(int domain, int type, int protocol) throws com.sun.jna.LastErrorException
      Creates a socket and returns a file descriptor for it.
      Parameters:
      domain - socket domain; use Sockets.AF_UNIX
      type - socket type; use Sockets.SOCK_STREAM
      protocol - socket communication protocol; use Sockets.DEFAULT_PROTOCOL.
      Returns:
      file descriptor for the socket; should be closed eventually, or -1 on error.
      Throws:
      com.sun.jna.LastErrorException - on errors
      See Also:
      • LibCAPI.close(int)
    • fcntl

      int fcntl(int fd, int command, int flag) throws com.sun.jna.LastErrorException
      Simple binding to fcntl; used to set the FD_CLOEXEC flag. On OS X, we cannot include SOCK_CLOEXEC in the socket() call.
      Parameters:
      fd - file descriptor to operate on
      command - set to F_SETFD
      flag - zero to clear the close-on-exec flag, FD_CLOEXEC to set it
      Returns:
      -1 on error, otherwise a value >= 0
      Throws:
      com.sun.jna.LastErrorException
    • connect

      int connect(int fd, Sockets.SockAddr addr, int addrLen) throws com.sun.jna.LastErrorException
      Connects a file descriptor, which must refer to a socket, to a Sockets.SockAddr.
      Parameters:
      fd - file descriptor of the socket, as returned by socket(int, int, int)
      addr - address to connect to
      addrLen - Length of addr, use Structure.size()
      Returns:
      0 on success; -1 otherwise
      Throws:
      com.sun.jna.LastErrorException - on errors
    • read

      com.sun.jna.platform.unix.LibCAPI.ssize_t read(int fd, byte[] buf, com.sun.jna.platform.unix.LibCAPI.size_t bufLen) throws com.sun.jna.LastErrorException
      Read data from a file descriptor.
      Parameters:
      fd - file descriptor to read from
      buf - buffer to read into
      bufLen - maximum number of bytes to read; at most length of buf
      Returns:
      number of bytes actually read; zero for EOF, -1 on error
      Throws:
      com.sun.jna.LastErrorException - on errors
    • write

      com.sun.jna.platform.unix.LibCAPI.ssize_t write(int fd, byte[] data, com.sun.jna.platform.unix.LibCAPI.size_t dataLen) throws com.sun.jna.LastErrorException
      Write data to a file descriptor.
      Parameters:
      fd - file descriptor to write to
      data - data to write
      dataLen - number of bytes to write
      Returns:
      number of bytes actually written; -1 on error
      Throws:
      com.sun.jna.LastErrorException - on errors