Socket (Apache Tomcat 8.5.55 API Documentation)

org.apache.tomcat.jni

## Class Socket

- java.lang.Object
- - org.apache.tomcat.jni.Socket

-     public class Socket
      extends Object

  Socket
  Author:
    Mladen Turk

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `APR_INCOMPLETE_READ` Set on non-blocking sockets (timeout !
    `static int` | `APR_INCOMPLETE_WRITE` like APR_INCOMPLETE_READ, but for write
    `static int` | `APR_INET`
    `static int` | `APR_INET6`
    `static int` | `APR_IPV4_ADDR_OK` no longer allow read or write requests
    `static int` | `APR_IPV6_ADDR_OK`
    `static int` | `APR_IPV6_V6ONLY` Don't accept IPv4 connections on an IPv6 listening socket.
    `static int` | `APR_LOCAL` Enum to tell us if we're interested in remote or local socket apr_interface_e
    `static int` | `APR_PROTO_SCTP` UDP
    `static int` | `APR_PROTO_TCP`
    `static int` | `APR_PROTO_UDP` TCP
    `static int` | `APR_REMOTE`
    `static int` | `APR_RESET_NODELAY` This flag is ONLY set internally when we set APR_TCP_NOPUSH with APR_TCP_NODELAY set to tell us that APR_TCP_NODELAY should be turned on again when NOPUSH is turned off
    `static int` | `APR_SHUTDOWN_READ` Define what type of socket shutdown should occur.
    `static int` | `APR_SHUTDOWN_READWRITE` no longer allow write requests
    `static int` | `APR_SHUTDOWN_WRITE` no longer allow read request
    `static int` | `APR_SO_DEBUG` Keepalive
    `static int` | `APR_SO_DISCONNECTED` Receive buffer
    `static int` | `APR_SO_KEEPALIVE` Linger
    `static int` | `APR_SO_LINGER`
    `static int` | `APR_SO_NONBLOCK` Debug
    `static int` | `APR_SO_RCVBUF` Send buffer
    `static int` | `APR_SO_REUSEADDR` Non-blocking IO
    `static int` | `APR_SO_SNDBUF` Reuse addresses
    `static int` | `APR_TCP_DEFER_ACCEPT` Delay accepting of new connections until data is available.
    `static int` | `APR_TCP_NODELAY` For SCTP sockets, this is mapped to STCP_NODELAY internally.
    `static int` | `APR_TCP_NOPUSH`
    `static int` | `APR_UNSPEC`
    `static int` | `SOCK_DGRAM`
    `static int` | `SOCK_STREAM`
    `static int` | `SOCKET_GET_APRS`
    `static int` | `SOCKET_GET_IMPL`
    `static int` | `SOCKET_GET_POOL`
    `static int` | `SOCKET_GET_TYPE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Socket()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static long` | `accept(long sock)` Accept a new connection request
    `static int` | `acceptfilter(long sock, String name, String args)` Set an OS level accept filter.
    `static long` | `acceptx(long sock, long pool)` Accept a new connection request
    `static boolean` | `atmark(long sock)` Query the specified socket if at the OOB/Urgent data mark
    `static int` | `bind(long sock, long sa)` Bind the socket to its associated port
    `static int` | `close(long thesocket)` Close a socket.
    `static int` | `connect(long sock, long sa)` Issue a connection request to a socket either on the same machine or a different one.
    `static long` | `create(int family, int type, int protocol, long cont)` Create a socket.
    `static Object` | `dataGet(long sock, String key)` Return the data associated with the current socket
    `static int` | `dataSet(long sock, String key, Object data)` Set the data associated with the current socket.
    `static void` | `destroy(long thesocket)` Destroy a pool associated with socket
    `static int` | `listen(long sock, int backlog)` Listen to a bound socket for connections.
    `static int` | `optGet(long sock, int opt)` Query socket options for the specified socket
    `static int` | `optSet(long sock, int opt, int on)` Setup socket options for the specified socket
    `static long` | `pool(long thesocket)` Create a child pool from associated socket pool.
    `static int` | `recv(long sock, byte[] buf, int offset, int nbytes)` Read data from a network.
    `static int` | `recvb(long sock, ByteBuffer buf, int offset, int nbytes)` Read data from a network.
    `static int` | `recvbb(long sock, int offset, int nbytes)` Read data from a network using internally set ByteBuffer.
    `static int` | `recvbbt(long sock, int offset, int nbytes, long timeout)` Read data from a network with timeout using internally set ByteBuffer
    `static int` | `recvbt(long sock, ByteBuffer buf, int offset, int nbytes, long timeout)` Read data from a network with timeout.
    `static int` | `recvfrom(long from, long sock, int flags, byte[] buf, int offset, int nbytes)`
    `static int` | `recvt(long sock, byte[] buf, int offset, int nbytes, long timeout)` Read data from a network with timeout.
    `static int` | `send(long sock, byte[] buf, int offset, int len)` Send data over a network.
    `static int` | `sendb(long sock, ByteBuffer buf, int offset, int len)` Send data over a network.
    `static int` | `sendbb(long sock, int offset, int len)` Send data over a network using internally set ByteBuffer
    `static long` | `sendfile(long sock, long file, byte[][] headers, byte[][] trailers, long offset, long len, int flags)` Send a file from an open file descriptor to a socket, along with optional headers and trailers.
    `static long` | `sendfilen(long sock, long file, long offset, long len, int flags)` Send a file without header and trailer arrays.
    `static int` | `sendib(long sock, ByteBuffer buf, int offset, int len)` Send data over a network without retry This functions acts like a blocking write by default.
    `static int` | `sendibb(long sock, int offset, int len)` Send data over a network using internally set ByteBuffer without internal retry.
    `static int` | `sendto(long sock, long where, int flags, byte[] buf, int offset, int len)`
    `static int` | `sendv(long sock, byte[][] vec)` Send multiple packets of data over a network.
    `static void` | `setrbb(long sock, ByteBuffer buf)` Set internal receive ByteBuffer.
    `static void` | `setsbb(long sock, ByteBuffer buf)` Set internal send ByteBuffer.
    `static int` | `shutdown(long thesocket, int how)` Shutdown either reading, writing, or both sides of a socket.
    `static long` | `timeoutGet(long sock)` Query socket timeout for the specified socket
    `static int` | `timeoutSet(long sock, long t)` Setup socket timeout for the specified socket

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### SOCK_STREAM

          public static final int SOCK_STREAM

      See Also:
        Constant Field Values

    - #### SOCK_DGRAM

          public static final int SOCK_DGRAM

      See Also:
        Constant Field Values

    - #### APR_SO_LINGER

          public static final int APR_SO_LINGER

      See Also:
        Constant Field Values

    - #### APR_SO_KEEPALIVE

          public static final int APR_SO_KEEPALIVE

      Linger
      See Also:
        Constant Field Values

    - #### APR_SO_DEBUG

          public static final int APR_SO_DEBUG

      Keepalive
      See Also:
        Constant Field Values

    - #### APR_SO_NONBLOCK

          public static final int APR_SO_NONBLOCK

      Debug
      See Also:
        Constant Field Values

    - #### APR_SO_REUSEADDR

          public static final int APR_SO_REUSEADDR

      Non-blocking IO
      See Also:
        Constant Field Values

    - #### APR_SO_SNDBUF

          public static final int APR_SO_SNDBUF

      Reuse addresses
      See Also:
        Constant Field Values

    - #### APR_SO_RCVBUF

          public static final int APR_SO_RCVBUF

      Send buffer
      See Also:
        Constant Field Values

    - #### APR_SO_DISCONNECTED

          public static final int APR_SO_DISCONNECTED

      Receive buffer
      See Also:
        Constant Field Values

    - #### APR_TCP_NODELAY

          public static final int APR_TCP_NODELAY

      For SCTP sockets, this is mapped to STCP_NODELAY internally.
      See Also:
        Constant Field Values

    - #### APR_TCP_NOPUSH

          public static final int APR_TCP_NOPUSH

      See Also:
        Constant Field Values

    - #### APR_RESET_NODELAY

          public static final int APR_RESET_NODELAY

      This flag is ONLY set internally when we set APR_TCP_NOPUSH with APR_TCP_NODELAY set to tell us that APR_TCP_NODELAY should be turned on again when NOPUSH is turned off
      See Also:
        Constant Field Values

    - #### APR_INCOMPLETE_READ

          public static final int APR_INCOMPLETE_READ

      Set on non-blocking sockets (timeout != 0) on which the previous read() did not fill a buffer completely. the next apr_socket_recv() will first call select()/poll() rather than going straight into read(). (Can also be set by an application to force a select()/poll() call before the next read, in cases where the app expects that an immediate read would fail.)
      See Also:
        Constant Field Values

    - #### APR_INCOMPLETE_WRITE

          public static final int APR_INCOMPLETE_WRITE

      like APR_INCOMPLETE_READ, but for write
      See Also:
        Constant Field Values

    - #### APR_IPV6_V6ONLY

          public static final int APR_IPV6_V6ONLY

      Don't accept IPv4 connections on an IPv6 listening socket.
      See Also:
        Constant Field Values

    - #### APR_TCP_DEFER_ACCEPT

          public static final int APR_TCP_DEFER_ACCEPT

      Delay accepting of new connections until data is available.
      See Also:
        Constant Field Values

    - #### APR_SHUTDOWN_READ

          public static final int APR_SHUTDOWN_READ

      Define what type of socket shutdown should occur. apr_shutdown_how_e enum
      See Also:
        Constant Field Values

    - #### APR_SHUTDOWN_WRITE

          public static final int APR_SHUTDOWN_WRITE

      no longer allow read request
      See Also:
        Constant Field Values

    - #### APR_SHUTDOWN_READWRITE

          public static final int APR_SHUTDOWN_READWRITE

      no longer allow write requests
      See Also:
        Constant Field Values

    - #### APR_IPV4_ADDR_OK

          public static final int APR_IPV4_ADDR_OK

      no longer allow read or write requests
      See Also:
        Constant Field Values

    - #### APR_IPV6_ADDR_OK

          public static final int APR_IPV6_ADDR_OK

      See Also:
        Constant Field Values

    - #### APR_UNSPEC

          public static final int APR_UNSPEC

      See Also:
        Constant Field Values

    - #### APR_INET

          public static final int APR_INET

      See Also:
        Constant Field Values

    - #### APR_INET6

          public static final int APR_INET6

      See Also:
        Constant Field Values

    - #### APR_PROTO_TCP

          public static final int APR_PROTO_TCP

      See Also:
        Constant Field Values

    - #### APR_PROTO_UDP

          public static final int APR_PROTO_UDP

      TCP
      See Also:
        Constant Field Values

    - #### APR_PROTO_SCTP

          public static final int APR_PROTO_SCTP

      UDP
      See Also:
        Constant Field Values

    - #### APR_LOCAL

          public static final int APR_LOCAL

      Enum to tell us if we're interested in remote or local socket apr_interface_e
      See Also:
        Constant Field Values

    - #### APR_REMOTE

          public static final int APR_REMOTE

      See Also:
        Constant Field Values

    - #### SOCKET_GET_POOL

          public static final int SOCKET_GET_POOL

      See Also:
        Constant Field Values

    - #### SOCKET_GET_IMPL

          public static final int SOCKET_GET_IMPL

      See Also:
        Constant Field Values

    - #### SOCKET_GET_APRS

          public static final int SOCKET_GET_APRS

      See Also:
        Constant Field Values

    - #### SOCKET_GET_TYPE

          public static final int SOCKET_GET_TYPE

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### Socket

          public Socket()

  - ### Method Detail

    - #### create

          public static long create(int family,
                    int type,
                    int protocol,
                    long cont)
                             throws Exception

      Create a socket.
      Parameters:
        `family` - The address family of the socket (e.g., APR_INET).
        `type` - The type of the socket (e.g., SOCK_STREAM).
        `protocol` - The protocol of the socket (e.g., APR_PROTO_TCP).
        `cont` - The parent pool to use
      Returns:
        The new socket that has been set up.
      Throws:
        `Exception` - Error creating socket

    - #### shutdown

          public static int shutdown(long thesocket,
                     int how)

      Shutdown either reading, writing, or both sides of a socket.
      This does not actually close the socket descriptor, it just controls which calls are still valid on the socket.
      Parameters:
        `thesocket` - The socket to close
        `how` - How to shutdown the socket. One of:

             APR_SHUTDOWN_READ         no longer allow read requests
             APR_SHUTDOWN_WRITE        no longer allow write requests
             APR_SHUTDOWN_READWRITE    no longer allow read or write requests

      Returns:
        the operation status

    - #### close

          public static int close(long thesocket)

      Close a socket.
      Parameters:
        `thesocket` - The socket to close
      Returns:
        the operation status

    - #### destroy

          public static void destroy(long thesocket)

      Destroy a pool associated with socket
      Parameters:
        `thesocket` - The destroy

    - #### bind

          public static int bind(long sock,
                 long sa)

      Bind the socket to its associated port
      Parameters:
        `sock` - The socket to bind
        `sa` - The socket address to bind to This may be where we will find out if there is any other process using the selected port.
      Returns:
        the operation status

    - #### listen

          public static int listen(long sock,
                   int backlog)

      Listen to a bound socket for connections.
      Parameters:
        `sock` - The socket to listen on
        `backlog` - The number of outstanding connections allowed in the sockets listen queue. If this value is less than zero, the listen queue size is set to zero.
      Returns:
        the operation status

    - #### acceptx

          public static long acceptx(long sock,
                     long pool)
                              throws Exception

      Accept a new connection request
      Parameters:
        `sock` - The socket we are listening on.
        `pool` - The pool for the new socket.
      Returns:
        A copy of the socket that is connected to the socket that made the connection request. This is the socket which should be used for all future communication.
      Throws:
        `Exception` - Socket accept error

    - #### accept

          public static long accept(long sock)
                             throws Exception

      Accept a new connection request
      Parameters:
        `sock` - The socket we are listening on.
      Returns:
        A copy of the socket that is connected to the socket that made the connection request. This is the socket which should be used for all future communication.
      Throws:
        `Exception` - Socket accept error

    - #### acceptfilter

          public static int acceptfilter(long sock,
                         String name,
                         String args)

      Set an OS level accept filter.
      Parameters:
        `sock` - The socket to put the accept filter on.
        `name` - The accept filter
        `args` - Any extra args to the accept filter. Passing NULL here removes the accept filter.
      Returns:
        the operation status

    - #### atmark

          public static boolean atmark(long sock)

      Query the specified socket if at the OOB/Urgent data mark
      Parameters:
        `sock` - The socket to query
      Returns:
        `true` if socket is at the OOB/urgent mark, otherwise `false`.

    - #### connect

          public static int connect(long sock,
                    long sa)

      Issue a connection request to a socket either on the same machine or a different one.
      Parameters:
        `sock` - The socket we wish to use for our side of the connection
        `sa` - The address of the machine we wish to connect to.
      Returns:
        the operation status

    - #### send

          public static int send(long sock,
                 byte[] buf,
                 int offset,
                 int len)

      Send data over a network.

           This functions acts like a blocking write by default.  To change
           this behavior, use apr_socket_timeout_set() or the APR_SO_NONBLOCK
           socket option.

           It is possible for both bytes to be sent and an error to be returned.

           APR_EINTR is never returned.

      Parameters:
        `sock` - The socket to send the data over.
        `buf` - The buffer which contains the data to be sent.
        `offset` - Offset in the byte buffer.
        `len` - The number of bytes to write; (-1) for full array.
      Returns:
        The number of bytes sent

    - #### sendb

          public static int sendb(long sock,
                  ByteBuffer buf,
                  int offset,
                  int len)

      Send data over a network.

           This functions acts like a blocking write by default.  To change
           this behavior, use apr_socket_timeout_set() or the APR_SO_NONBLOCK
           socket option.

           It is possible for both bytes to be sent and an error to be returned.

           APR_EINTR is never returned.

      Parameters:
        `sock` - The socket to send the data over.
        `buf` - The Byte buffer which contains the data to be sent.
        `offset` - The offset within the buffer array of the first buffer from which bytes are to be retrieved; must be non-negative and no larger than buf.length
        `len` - The maximum number of buffers to be accessed; must be non-negative and no larger than buf.length - offset
      Returns:
        The number of bytes sent

    - #### sendib

          public static int sendib(long sock,
                   ByteBuffer buf,
                   int offset,
                   int len)

      Send data over a network without retry

           This functions acts like a blocking write by default.  To change
           this behavior, use apr_socket_timeout_set() or the APR_SO_NONBLOCK
           socket option.

           It is possible for both bytes to be sent and an error to be returned.

      Parameters:
        `sock` - The socket to send the data over.
        `buf` - The Byte buffer which contains the data to be sent.
        `offset` - The offset within the buffer array of the first buffer from which bytes are to be retrieved; must be non-negative and no larger than buf.length
        `len` - The maximum number of buffers to be accessed; must be non-negative and no larger than buf.length - offset
      Returns:
        The number of bytes sent

    - #### sendbb

          public static int sendbb(long sock,
                   int offset,
                   int len)

      Send data over a network using internally set ByteBuffer
      Parameters:
        `sock` - The socket to send the data over.
        `offset` - The offset within the buffer array of the first buffer from which bytes are to be retrieved; must be non-negative and no larger than buf.length
        `len` - The maximum number of buffers to be accessed; must be non-negative and no larger than buf.length - offset
      Returns:
        The number of bytes sent

    - #### sendibb

          public static int sendibb(long sock,
                    int offset,
                    int len)

      Send data over a network using internally set ByteBuffer without internal retry.
      Parameters:
        `sock` - The socket to send the data over.
        `offset` - The offset within the buffer array of the first buffer from which bytes are to be retrieved; must be non-negative and no larger than buf.length
        `len` - The maximum number of buffers to be accessed; must be non-negative and no larger than buf.length - offset
      Returns:
        The number of bytes sent

    - #### sendv

          public static int sendv(long sock,
                  byte[][] vec)

      Send multiple packets of data over a network.

           This functions acts like a blocking write by default.  To change
           this behavior, use apr_socket_timeout_set() or the APR_SO_NONBLOCK
           socket option.
           The number of bytes actually sent is stored in argument 3.

           It is possible for both bytes to be sent and an error to be returned.

           APR_EINTR is never returned.

      Parameters:
        `sock` - The socket to send the data over.
        `vec` - The array from which to get the data to send.
      Returns:
        The number of bytes sent

    - #### sendto

          public static int sendto(long sock,
                   long where,
                   int flags,
                   byte[] buf,
                   int offset,
                   int len)

      Parameters:
        `sock` - The socket to send from
        `where` - The apr_sockaddr_t describing where to send the data
        `flags` - The flags to use
        `buf` - The data to send
        `offset` - Offset in the byte buffer.
        `len` - The length of the data to send
      Returns:
        The number of bytes sent

    - #### recv

          public static int recv(long sock,
                 byte[] buf,
                 int offset,
                 int nbytes)

      Read data from a network.

           This functions acts like a blocking read by default.  To change
           this behavior, use apr_socket_timeout_set() or the APR_SO_NONBLOCK
           socket option.
           The number of bytes actually received is stored in argument 3.

           It is possible for both bytes to be received and an APR_EOF or
           other error to be returned.

           APR_EINTR is never returned.

      Parameters:
        `sock` - The socket to read the data from.
        `buf` - The buffer to store the data in.
        `offset` - Offset in the byte buffer.
        `nbytes` - The number of bytes to read (-1) for full array.
      Returns:
        the number of bytes received.

    - #### recvt

          public static int recvt(long sock,
                  byte[] buf,
                  int offset,
                  int nbytes,
                  long timeout)

      Read data from a network with timeout.

           This functions acts like a blocking read by default.  To change
           this behavior, use apr_socket_timeout_set() or the APR_SO_NONBLOCK
           socket option.
           The number of bytes actually received is stored in argument 3.

           It is possible for both bytes to be received and an APR_EOF or
           other error to be returned.

           APR_EINTR is never returned.

      Parameters:
        `sock` - The socket to read the data from.
        `buf` - The buffer to store the data in.
        `offset` - Offset in the byte buffer.
        `nbytes` - The number of bytes to read (-1) for full array.
        `timeout` - The socket timeout in microseconds.
      Returns:
        the number of bytes received.

    - #### recvb

          public static int recvb(long sock,
                  ByteBuffer buf,
                  int offset,
                  int nbytes)

      Read data from a network.

           This functions acts like a blocking read by default.  To change
           this behavior, use apr_socket_timeout_set() or the APR_SO_NONBLOCK
           socket option.
           The number of bytes actually received is stored in argument 3.

           It is possible for both bytes to be received and an APR_EOF or
           other error to be returned.

           APR_EINTR is never returned.

      Parameters:
        `sock` - The socket to read the data from.
        `buf` - The buffer to store the data in.
        `offset` - Offset in the byte buffer.
        `nbytes` - The number of bytes to read (-1) for full array.
      Returns:
        If ≥ 0, the return value is the number of bytes read. Note a non-blocking read with no data current available will return `Status.EAGAIN` and EOF will return `Status.APR_EOF`.

    - #### recvbb

          public static int recvbb(long sock,
                   int offset,
                   int nbytes)

      Read data from a network using internally set ByteBuffer.
      Parameters:
        `sock` - The socket to read the data from.
        `offset` - Offset in the byte buffer.
        `nbytes` - The number of bytes to read (-1) for full array.
      Returns:
        If > 0, the return value is the number of bytes read. If == 0, the return value indicates EOF and if < 0 the return value is the error code. Note a non-blocking read with no data current available will return `Status.EAGAIN` not zero.

    - #### recvbt

          public static int recvbt(long sock,
                   ByteBuffer buf,
                   int offset,
                   int nbytes,
                   long timeout)

      Read data from a network with timeout.

           This functions acts like a blocking read by default.  To change
           this behavior, use apr_socket_timeout_set() or the APR_SO_NONBLOCK
           socket option.
           The number of bytes actually received is stored in argument 3.

           It is possible for both bytes to be received and an APR_EOF or
           other error to be returned.

           APR_EINTR is never returned.

      Parameters:
        `sock` - The socket to read the data from.
        `buf` - The buffer to store the data in.
        `offset` - Offset in the byte buffer.
        `nbytes` - The number of bytes to read (-1) for full array.
        `timeout` - The socket timeout in microseconds.
      Returns:
        the number of bytes received.

    - #### recvbbt

          public static int recvbbt(long sock,
                    int offset,
                    int nbytes,
                    long timeout)

      Read data from a network with timeout using internally set ByteBuffer
      Parameters:
        `sock` - The socket to read the data from.
        `offset` - Offset in the byte buffer.
        `nbytes` - The number of bytes to read (-1) for full array.
        `timeout` - The socket timeout in microseconds.
      Returns:
        the number of bytes received.

    - #### recvfrom

          public static int recvfrom(long from,
                     long sock,
                     int flags,
                     byte[] buf,
                     int offset,
                     int nbytes)

      Parameters:
        `from` - The apr_sockaddr_t to fill in the recipient info
        `sock` - The socket to use
        `flags` - The flags to use
        `buf` - The buffer to use
        `offset` - Offset in the byte buffer.
        `nbytes` - The number of bytes to read (-1) for full array.
      Returns:
        the number of bytes received.

    - #### optSet

          public static int optSet(long sock,
                   int opt,
                   int on)

      Setup socket options for the specified socket
      Parameters:
        `sock` - The socket to set up.
        `opt` - The option we would like to configure. One of:

             APR_SO_DEBUG      --  turn on debugging information
             APR_SO_KEEPALIVE  --  keep connections active
             APR_SO_LINGER     --  lingers on close if data is present
             APR_SO_NONBLOCK   --  Turns blocking on/off for socket
                                   When this option is enabled, use
                                   the APR_STATUS_IS_EAGAIN() macro to
                                   see if a send or receive function
                                   could not transfer data without
                                   blocking.
             APR_SO_REUSEADDR  --  The rules used in validating addresses
                                   supplied to bind should allow reuse
                                   of local addresses.
             APR_SO_SNDBUF     --  Set the SendBufferSize
             APR_SO_RCVBUF     --  Set the ReceiveBufferSize

        `on` - Value for the option.
      Returns:
        the operation status

    - #### optGet

          public static int optGet(long sock,
                   int opt)
                            throws Exception

      Query socket options for the specified socket
      Parameters:
        `sock` - The socket to query
        `opt` - The option we would like to query. One of:

             APR_SO_DEBUG      --  turn on debugging information
             APR_SO_KEEPALIVE  --  keep connections active
             APR_SO_LINGER     --  lingers on close if data is present
             APR_SO_NONBLOCK   --  Turns blocking on/off for socket
             APR_SO_REUSEADDR  --  The rules used in validating addresses
                                   supplied to bind should allow reuse
                                   of local addresses.
             APR_SO_SNDBUF     --  Set the SendBufferSize
             APR_SO_RCVBUF     --  Set the ReceiveBufferSize
             APR_SO_DISCONNECTED -- Query the disconnected state of the socket.
                                   (Currently only used on Windows)

      Returns:
        Socket option returned on the call.
      Throws:
        `Exception` - An error occurred

    - #### timeoutSet

          public static int timeoutSet(long sock,
                       long t)

      Setup socket timeout for the specified socket
      Parameters:
        `sock` - The socket to set up.
        `t` - Value for the timeout in microseconds.

             t > 0  -- read and write calls return APR_TIMEUP if specified time
                       elapses with no data read or written
             t == 0 -- read and write calls never block
             t < 0  -- read and write calls block

      Returns:
        the operation status

    - #### timeoutGet

          public static long timeoutGet(long sock)
                                 throws Exception

      Query socket timeout for the specified socket
      Parameters:
        `sock` - The socket to query
      Returns:
        Socket timeout returned from the query.
      Throws:
        `Exception` - An error occurred

    - #### sendfile

          public static long sendfile(long sock,
                      long file,
                      byte[][] headers,
                      byte[][] trailers,
                      long offset,
                      long len,
                      int flags)

      Send a file from an open file descriptor to a socket, along with optional headers and trailers.
      This functions acts like a blocking write by default. To change this behavior, use apr_socket_timeout_set() or the APR_SO_NONBLOCK socket option. The number of bytes actually sent is stored in the len parameter. The offset parameter is passed by reference for no reason; its value will never be modified by the apr_socket_sendfile() function.
      Parameters:
        `sock` - The socket to which we're writing
        `file` - The open file from which to read
        `headers` - Array containing the headers to send
        `trailers` - Array containing the trailers to send
        `offset` - Offset into the file where we should begin writing
        `len` - Number of bytes to send from the file
        `flags` - APR flags that are mapped to OS specific flags
      Returns:
        Number of bytes actually sent, including headers, file, and trailers

    - #### sendfilen

          public static long sendfilen(long sock,
                       long file,
                       long offset,
                       long len,
                       int flags)

      Send a file without header and trailer arrays.
      Parameters:
        `sock` - The socket to which we're writing
        `file` - The open file from which to read
        `offset` - Offset into the file where we should begin writing
        `len` - Number of bytes to send from the file
        `flags` - APR flags that are mapped to OS specific flags
      Returns:
        Number of bytes actually sent

    - #### pool

          public static long pool(long thesocket)
                           throws Exception

      Create a child pool from associated socket pool.
      Parameters:
        `thesocket` - The socket to use
      Returns:
        a pointer to the pool
      Throws:
        `Exception` - An error occurred

    - #### setsbb

          public static void setsbb(long sock,
                    ByteBuffer buf)

      Set internal send ByteBuffer. This function will preset internal Java ByteBuffer for consecutive sendbb calls.
      Parameters:
        `sock` - The socket to use
        `buf` - The ByteBuffer

    - #### setrbb

          public static void setrbb(long sock,
                    ByteBuffer buf)

      Set internal receive ByteBuffer. This function will preset internal Java ByteBuffer for consecutive revcvbb/recvbbt calls.
      Parameters:
        `sock` - The socket to use
        `buf` - The ByteBuffer

    - #### dataSet

          public static int dataSet(long sock,
                    String key,
                    Object data)

      Set the data associated with the current socket.
      Parameters:
        `sock` - The currently open socket.
        `data` - The user data to associate with the socket.
        `key` - The key to associate with the data.
      Returns:
        the operation status

    - #### dataGet

          public static Object dataGet(long sock,
                       String key)

      Return the data associated with the current socket
      Parameters:
        `sock` - The currently open socket.
        `key` - The key to associate with the user data.
      Returns:
        Data or null in case of error.

Copyright © 2000-2020 Apache Software Foundation. All Rights Reserved.