📄 socket.java
字号:
public static native int sendv(long sock, byte[][] vec);
/**
* @param sock The socket to send from
* @param where The apr_sockaddr_t describing where to send the data
* @param flags The flags to use
* @param buf The data to send
* @param offset Offset in the byte buffer.
* @param len The length of the data to send
*/
public static native int sendto(long sock, long where, int flags,
byte[] buf, int offset, int len);
/**
* Read data from a network.
*
* <PRE>
* 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.
* </PRE>
* @param sock The socket to read the data from.
* @param buf The buffer to store the data in.
* @param offset Offset in the byte buffer.
* @param nbytes The number of bytes to read (-1) for full array.
* @return the number of bytes received.
*/
public static native int recv(long sock, byte[] buf, int offset, int nbytes);
/**
* Read data from a network with timeout.
*
* <PRE>
* 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.
* </PRE>
* @param sock The socket to read the data from.
* @param buf The buffer to store the data in.
* @param offset Offset in the byte buffer.
* @param nbytes The number of bytes to read (-1) for full array.
* @param timeout The socket timeout in microseconds.
* @return the number of bytes received.
*/
public static native int recvt(long sock, byte[] buf, int offset,
int nbytes, long timeout);
/**
* Read data from a network.
*
* <PRE>
* 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.
* </PRE>
* @param sock The socket to read the data from.
* @param buf The buffer to store the data in.
* @param offset Offset in the byte buffer.
* @param nbytes The number of bytes to read (-1) for full array.
* @return the number of bytes received.
*/
public static native int recvb(long sock, ByteBuffer buf,
int offset, int nbytes);
/**
* Read data from a network using internally set ByteBuffer
*/
public static native int recvbb(long sock,
int offset, int nbytes);
/**
* Read data from a network with timeout.
*
* <PRE>
* 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.
* </PRE>
* @param sock The socket to read the data from.
* @param buf The buffer to store the data in.
* @param offset Offset in the byte buffer.
* @param nbytes The number of bytes to read (-1) for full array.
* @param timeout The socket timeout in microseconds.
* @return the number of bytes received.
*/
public static native int recvbt(long sock, ByteBuffer buf,
int offset, int nbytes, long timeout);
/**
* Read data from a network with timeout using internally set ByteBuffer
*/
public static native int recvbbt(long sock,
int offset, int nbytes, long timeout);
/**
* @param from The apr_sockaddr_t to fill in the recipient info
* @param sock The socket to use
* @param flags The flags to use
* @param buf The buffer to use
* @param offset Offset in the byte buffer.
* @param nbytes The number of bytes to read (-1) for full array.
* @return the number of bytes received.
*/
public static native int recvFrom(long from, long sock, int flags,
byte[] buf, int offset, int nbytes);
/**
* Setup socket options for the specified socket
* @param sock The socket to set up.
* @param opt The option we would like to configure. One of:
* <PRE>
* 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
* </PRE>
* @param on Value for the option.
*/
public static native int optSet(long sock, int opt, int on);
/**
* Query socket options for the specified socket
* @param sock The socket to query
* @param opt The option we would like to query. One of:
* <PRE>
* 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)
* </PRE>
* @return Socket option returned on the call.
*/
public static native int optGet(long sock, int opt)
throws Exception;
/**
* Setup socket timeout for the specified socket
* @param sock The socket to set up.
* @param t Value for the timeout in microseconds.
* <PRE>
* t > 0 -- read and write calls return APR_TIMEUP if specified time
* elapsess with no data read or written
* t == 0 -- read and write calls never block
* t < 0 -- read and write calls block
* </PRE>
*/
public static native int timeoutSet(long sock, long t);
/**
* Query socket timeout for the specified socket
* @param sock The socket to query
* @return Socket timeout returned from the query.
*/
public static native long timeoutGet(long sock)
throws Exception;
/**
* Send a file from an open file descriptor to a socket, along with
* optional headers and trailers.
* <br />
* 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.
* @param sock The socket to which we're writing
* @param file The open file from which to read
* @param headers Array containing the headers to send
* @param trailers Array containing the trailers to send
* @param offset Offset into the file where we should begin writing
* @param len Number of bytes to send from the file
* @param flags APR flags that are mapped to OS specific flags
* @return Number of bytes actually sent, including headers,
* file, and trailers
*
*/
public static native long sendfile(long sock, long file, byte [][] headers,
byte[][] trailers, long offset,
long len, int flags);
/**
* Send a file without header and trailer arrays.
*/
public static native long sendfilen(long sock, long file, long offset,
long len, int flags);
/**
* Create a child pool from associated socket pool.
* @param thesocket The socket to use
*/
public static native long pool(long thesocket)
throws Exception;
/**
* Private method for geting the socket struct members
* @param socket The soocket to use
* @param what Struct member to obtain
* <PRE>
* SOCKET_GET_POOL - The socket pool
* SOCKET_GET_IMPL - The socket implementation object
* SOCKET_GET_APRS - APR socket
* SOCKET_GET_TYPE - Socket type
* </PRE>
* @return The stucture member address
*/
private static native long get(long socket, int what);
/**
* Set internal send ByteBuffer.
* This function will preset internal Java ByteBuffer for
* consecutive sendbb calls.
* @param thesocket The socket to use
* @param buf The ByteBuffer
*/
public static native void setsbb(long sock, ByteBuffer buf);
/**
* Set internal receive ByteBuffer.
* This function will preset internal Java ByteBuffer for
* consecutive revcvbb/recvbbt calls.
* @param thesocket The socket to use
* @param buf The ByteBuffer
*/
public static native void setrbb(long sock, ByteBuffer buf);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -