📄 apr_network_io.h
字号:
* @param offset Offset into the file where we should begin writing * @param len (input) - Number of bytes to send from the file * (output) - Number of bytes actually sent, * including headers, file, and trailers * @param flags APR flags that are mapped to OS specific flags * @remark This functions acts like a blocking write by default. To change * this behavior, use apr_socket_timeout_set(). * The number of bytes actually sent is stored in argument 5. */APR_DECLARE(apr_status_t) apr_socket_sendfile(apr_socket_t *sock, apr_file_t *file, apr_hdtr_t *hdtr, apr_off_t *offset, apr_size_t *len, apr_int32_t flags);/** @deprecated @see apr_socket_sendfile */APR_DECLARE(apr_status_t) apr_sendfile(apr_socket_t *sock, apr_file_t *file, apr_hdtr_t *hdtr, apr_off_t *offset, apr_size_t *len, apr_int32_t flags);#endif /* APR_HAS_SENDFILE *//** * Read data from a network. * @param sock The socket to read the data from. * @param buf The buffer to store the data in. * @param len On entry, the number of bytes to receive; on exit, the number * of bytes received. * @remark * <PRE> * This functions acts like a blocking read by default. To change * this behavior, use apr_socket_timeout_set(). * The number of bytes actually sent 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> */APR_DECLARE(apr_status_t) apr_socket_recv(apr_socket_t *sock, char *buf, apr_size_t *len);/** @deprecated @see apr_socket_recv */APR_DECLARE(apr_status_t) apr_recv(apr_socket_t *sock, char *buf, apr_size_t *len);/** * 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 * 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. */APR_DECLARE(apr_status_t) apr_socket_opt_set(apr_socket_t *sock, apr_int32_t opt, apr_int32_t on);/** @deprecated @see apr_socket_opt_set */APR_DECLARE(apr_status_t) apr_setsocketopt(apr_socket_t *sock, apr_int32_t opt, apr_int32_t on);/** * Setup socket timeout for the specified socket * @param sock The socket to set up. * @param t Value for the timeout. * <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> */APR_DECLARE(apr_status_t) apr_socket_timeout_set(apr_socket_t *sock, apr_interval_time_t t);/** * 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> * @param on Socket option returned on the call. */APR_DECLARE(apr_status_t) apr_socket_opt_get(apr_socket_t *sock, apr_int32_t opt, apr_int32_t *on);/** @deprecated @see apr_socket_opt_set */APR_DECLARE(apr_status_t) apr_getsocketopt(apr_socket_t *sock, apr_int32_t opt, apr_int32_t *on);/** * Query socket timeout for the specified socket * @param sock The socket to query * @param t Socket timeout returned from the query. */APR_DECLARE(apr_status_t) apr_socket_timeout_get(apr_socket_t *sock, apr_interval_time_t *t);/** * Query the specified socket if at the OOB/Urgent data mark * @param sock The socket to query * @param atmark Is set to true if socket is at the OOB/urgent mark, * otherwise is set to false. */APR_DECLARE(apr_status_t) apr_socket_atmark(apr_socket_t *sock, int *atmark);/** * Return an apr_sockaddr_t from an apr_socket_t * @param sa The returned apr_sockaddr_t. * @param which Which interface do we want the apr_sockaddr_t for? * @param sock The socket to use */APR_DECLARE(apr_status_t) apr_socket_addr_get(apr_sockaddr_t **sa, apr_interface_e which, apr_socket_t *sock); /** * Set the port in an APR socket address. * @param sockaddr The socket address to set. * @param port The port to be stored in the socket address. * @deprecated @see apr_sockaddr_info_get */APR_DECLARE(apr_status_t) apr_sockaddr_port_set(apr_sockaddr_t *sockaddr, apr_port_t port);/** * Return the port in an APR socket address. * @param port The port from the socket address. * @param sockaddr The socket address to reference. * @deprecated Access port field directly. */APR_DECLARE(apr_status_t) apr_sockaddr_port_get(apr_port_t *port, apr_sockaddr_t *sockaddr);/** * Set the IP address in an APR socket address. * @param sockaddr The socket address to use * @param addr The IP address to attach to the socket. * Use APR_ANYADDR to use any IP addr on the machine. * @deprecated @see apr_sockaddr_info_get */APR_DECLARE(apr_status_t) apr_sockaddr_ip_set(apr_sockaddr_t *sockaddr, const char *addr);/** * Return the IP address (in numeric address string format) in * an APR socket address. APR will allocate storage for the IP address * string from the pool of the apr_sockaddr_t. * @param addr The IP address. * @param sockaddr The socket address to reference. */APR_DECLARE(apr_status_t) apr_sockaddr_ip_get(char **addr, apr_sockaddr_t *sockaddr);/** * See if the IP addresses in two APR socket addresses are * equivalent. Appropriate logic is present for comparing * IPv4-mapped IPv6 addresses with IPv4 addresses. * * @param addr1 One of the APR socket addresses. * @param addr2 The other APR socket address. * @remark The return value will be non-zero if the addresses * are equivalent. */APR_DECLARE(int) apr_sockaddr_equal(const apr_sockaddr_t *addr1, const apr_sockaddr_t *addr2);#if APR_FILES_AS_SOCKETS || defined(DOXYGEN)/** * Convert a File type to a socket so that it can be used in a poll operation. * @param newsock the newly created socket which represents a file. * @param file the file to mask as a socket. * @warning This is not available on all platforms. Platforms that have the * ability to poll files for data to be read/written/exceptions will * have the APR_FILES_AS_SOCKETS macro defined as true. * @deprecated This function has been deprecated, because of the new poll * implementation. */APR_DECLARE(apr_status_t) apr_socket_from_file(apr_socket_t **newsock, apr_file_t *file);#endif /* APR_FILES_AS_SOCKETS *//** * Given an apr_sockaddr_t and a service name, set the port for the service * @param sockaddr The apr_sockaddr_t that will have its port set * @param servname The name of the service you wish to use */APR_DECLARE(apr_status_t) apr_getservbyname(apr_sockaddr_t *sockaddr, const char *servname);/** * Build an ip-subnet representation from an IP address and optional netmask or * number-of-bits. * @param ipsub The new ip-subnet representation * @param ipstr The input IP address string * @param mask_or_numbits The input netmask or number-of-bits string, or NULL * @param p The pool to allocate from */APR_DECLARE(apr_status_t) apr_ipsubnet_create(apr_ipsubnet_t **ipsub, const char *ipstr, const char *mask_or_numbits, apr_pool_t *p);/** * Test the IP address in an apr_sockaddr_t against a pre-built ip-subnet * representation. * @param ipsub The ip-subnet representation * @param sa The socket address to test * @return non-zero if the socket address is within the subnet, 0 otherwise */APR_DECLARE(int) apr_ipsubnet_test(apr_ipsubnet_t *ipsub, apr_sockaddr_t *sa);#if APR_HAS_SO_ACCEPTFILTER || defined(DOXYGEN)/** * Set an OS level accept filter. * @param sock The socket to put the accept filter on. * @param name The accept filter * @param args Any extra args to the accept filter. Passing NULL here removes * the accept filter. */apr_status_t apr_socket_accept_filter(apr_socket_t *sock, char *name, char *args);#endif/** * Return the protocol of the socket. * @param sock The socket to query. * @param protocol The returned protocol (e.g., APR_PROTO_TCP). */APR_DECLARE(apr_status_t) apr_socket_protocol_get(apr_socket_t *sock, int *protocol);/** * Set a socket to be inherited by child processes. */APR_DECLARE_INHERIT_SET(socket);/** @deprecated @see apr_socket_inherit_set */APR_DECLARE(void) apr_socket_set_inherit(apr_socket_t *skt);/** * Unset a socket from being inherited by child processes. */APR_DECLARE_INHERIT_UNSET(socket);/** @deprecated @see apr_socket_inherit_unset */APR_DECLARE(void) apr_socket_unset_inherit(apr_socket_t *skt);/** @} */#ifdef __cplusplus}#endif#endif /* ! APR_NETWORK_IO_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -