📄 socket.h
字号:
* Returns: * * ISC_R_SUCCESS * ISC_R_UNEXPECTED */isc_result_tisc_socket_accept(isc_socket_t *sock, isc_task_t *task, isc_taskaction_t action, const void *arg);/* * Queue accept event. When a new connection is received, the task will * get an ISC_SOCKEVENT_NEWCONN event with the sender set to the listen * socket. The new socket structure is sent inside the isc_socket_newconnev_t * event type, and is attached to the task 'task'. * * REQUIRES: * 'socket' is a valid TCP socket that isc_socket_listen() was called * on. * * 'task' is a valid task * * 'action' is a valid action * * RETURNS: * ISC_R_SUCCESS * ISC_R_NOMEMORY * ISC_R_UNEXPECTED */isc_result_tisc_socket_connect(isc_socket_t *sock, isc_sockaddr_t *addressp, isc_task_t *task, isc_taskaction_t action, const void *arg);/* * Connect 'socket' to peer with address *saddr. When the connection * succeeds, or when an error occurs, a CONNECT event with action 'action' * and arg 'arg' will be posted to the event queue for 'task'. * * Requires: * * 'socket' is a valid TCP socket * * 'addressp' points to a valid isc_sockaddr * * 'task' is a valid task * * 'action' is a valid action * * Returns: * * ISC_R_SUCCESS * ISC_R_NOMEMORY * ISC_R_UNEXPECTED * * Posted event's result code: * * ISC_R_SUCCESS * ISC_R_TIMEDOUT * ISC_R_CONNREFUSED * ISC_R_NETUNREACH * ISC_R_UNEXPECTED */isc_result_tisc_socket_getpeername(isc_socket_t *sock, isc_sockaddr_t *addressp);/* * Get the name of the peer connected to 'socket'. * * Requires: * * 'socket' is a valid TCP socket. * * Returns: * * ISC_R_SUCCESS * ISC_R_TOOSMALL * ISC_R_UNEXPECTED */isc_result_tisc_socket_getsockname(isc_socket_t *sock, isc_sockaddr_t *addressp);/* * Get the name of 'socket'. * * Requires: * * 'socket' is a valid socket. * * Returns: * * ISC_R_SUCCESS * ISC_R_TOOSMALL * ISC_R_UNEXPECTED */isc_result_tisc_socket_recv(isc_socket_t *sock, isc_region_t *region, unsigned int minimum, isc_task_t *task, isc_taskaction_t action, const void *arg);isc_result_tisc_socket_recvv(isc_socket_t *sock, isc_bufferlist_t *buflist, unsigned int minimum, isc_task_t *task, isc_taskaction_t action, const void *arg);isc_result_tisc_socket_recv2(isc_socket_t *sock, isc_region_t *region, unsigned int minimum, isc_task_t *task, isc_socketevent_t *event, unsigned int flags);/* * Receive from 'socket', storing the results in region. * * Notes: * * Let 'length' refer to the length of 'region' or to the sum of all * available regions in the list of buffers '*buflist'. * * If 'minimum' is non-zero and at least that many bytes are read, * the completion event will be posted to the task 'task.' If minimum * is zero, the exact number of bytes requested in the region must * be read for an event to be posted. This only makes sense for TCP * connections, and is always set to 1 byte for UDP. * * The read will complete when the desired number of bytes have been * read, if end-of-input occurs, or if an error occurs. A read done * event with the given 'action' and 'arg' will be posted to the * event queue of 'task'. * * The caller may not modify 'region', the buffers which are passed * into this function, or any data they refer to until the completion * event is received. * * For isc_socket_recvv(): * On successful completion, '*buflist' will be empty, and the list of * all buffers will be returned in the done event's 'bufferlist' * member. On error return, '*buflist' will be unchanged. * * For isc_socket_recv2(): * 'event' is not NULL, and the non-socket specific fields are * expected to be initialized. * * For isc_socket_recv2(): * The only defined value for 'flags' is ISC_SOCKFLAG_IMMEDIATE. If * set and the operation completes, the return value will be * ISC_R_SUCCESS and the event will be filled in and not sent. If the * operation does not complete, the return value will be * ISC_R_INPROGRESS and the event will be sent when the operation * completes. * * Requires: * * 'socket' is a valid, bound socket. * * For isc_socket_recv(): * 'region' is a valid region * * For isc_socket_recvv(): * 'buflist' is non-NULL, and '*buflist' contain at least one buffer. * * 'task' is a valid task * * For isc_socket_recv() and isc_socket_recvv(): * action != NULL and is a valid action * * For isc_socket_recv2(): * event != NULL * * Returns: * * ISC_R_SUCCESS * ISC_R_INPROGRESS * ISC_R_NOMEMORY * ISC_R_UNEXPECTED * * Event results: * * ISC_R_SUCCESS * ISC_R_UNEXPECTED * XXX needs other net-type errors */isc_result_tisc_socket_send(isc_socket_t *sock, isc_region_t *region, isc_task_t *task, isc_taskaction_t action, const void *arg);isc_result_tisc_socket_sendto(isc_socket_t *sock, isc_region_t *region, isc_task_t *task, isc_taskaction_t action, const void *arg, isc_sockaddr_t *address, struct in6_pktinfo *pktinfo);isc_result_tisc_socket_sendv(isc_socket_t *sock, isc_bufferlist_t *buflist, isc_task_t *task, isc_taskaction_t action, const void *arg);isc_result_tisc_socket_sendtov(isc_socket_t *sock, isc_bufferlist_t *buflist, isc_task_t *task, isc_taskaction_t action, const void *arg, isc_sockaddr_t *address, struct in6_pktinfo *pktinfo);isc_result_tisc_socket_sendto2(isc_socket_t *sock, isc_region_t *region, isc_task_t *task, isc_sockaddr_t *address, struct in6_pktinfo *pktinfo, isc_socketevent_t *event, unsigned int flags);/* * Send the contents of 'region' to the socket's peer. * * Notes: * * Shutting down the requestor's task *may* result in any * still pending writes being dropped or completed, depending on the * underlying OS implementation. * * If 'action' is NULL, then no completion event will be posted. * * The caller may not modify 'region', the buffers which are passed * into this function, or any data they refer to until the completion * event is received. * * For isc_socket_sendv() and isc_socket_sendtov(): * On successful completion, '*buflist' will be empty, and the list of * all buffers will be returned in the done event's 'bufferlist' * member. On error return, '*buflist' will be unchanged. * * For isc_socket_sendto2(): * 'event' is not NULL, and the non-socket specific fields are * expected to be initialized. * * For isc_socket_sendto2(): * The only defined values for 'flags' are ISC_SOCKFLAG_IMMEDIATE * and ISC_SOCKFLAG_NORETRY. * * If ISC_SOCKFLAG_IMMEDIATE is set and the operation completes, the * return value will be ISC_R_SUCCESS and the event will be filled * in and not sent. If the operation does not complete, the return * value will be ISC_R_INPROGRESS and the event will be sent when * the operation completes. * * ISC_SOCKFLAG_NORETRY can only be set for UDP sockets. If set * and the send operation fails due to a transient error, the send * will not be retried and the error will be indicated in the event. * Using this option along with ISC_SOCKFLAG_IMMEDIATE allows the caller * to specify a region that is allocated on the stack. * * Requires: * * 'socket' is a valid, bound socket. * * For isc_socket_send(): * 'region' is a valid region * * For isc_socket_sendv() and isc_socket_sendtov(): * 'buflist' is non-NULL, and '*buflist' contain at least one buffer. * * 'task' is a valid task * * For isc_socket_sendv(), isc_socket_sendtov(), isc_socket_send(), and * isc_socket_sendto(): * action == NULL or is a valid action * * For isc_socket_sendto2(): * event != NULL * * Returns: * * ISC_R_SUCCESS * ISC_R_INPROGRESS * ISC_R_NOMEMORY * ISC_R_UNEXPECTED * * Event results: * * ISC_R_SUCCESS * ISC_R_UNEXPECTED * XXX needs other net-type errors */isc_result_tisc_socketmgr_create(isc_mem_t *mctx, isc_socketmgr_t **managerp);/* * Create a socket manager. * * Notes: * * All memory will be allocated in memory context 'mctx'. * * Requires: * * 'mctx' is a valid memory context. * * 'managerp' points to a NULL isc_socketmgr_t. * * Ensures: * * '*managerp' is a valid isc_socketmgr_t. * * Returns: * * ISC_R_SUCCESS * ISC_R_NOMEMORY * ISC_R_UNEXPECTED */voidisc_socketmgr_destroy(isc_socketmgr_t **managerp);/* * Destroy a socket manager. * * Notes: * * This routine blocks until there are no sockets left in the manager, * so if the caller holds any socket references using the manager, it * must detach them before calling isc_socketmgr_destroy() or it will * block forever. * * Requires: * * '*managerp' is a valid isc_socketmgr_t. * * All sockets managed by this manager are fully detached. * * Ensures: * * *managerp == NULL * * All resources used by the manager have been freed. */isc_sockettype_tisc_socket_gettype(isc_socket_t *sock);/* * Returns the socket type for "sock." * * Requires: * * "sock" is a valid socket. */isc_boolean_tisc_socket_isbound(isc_socket_t *sock);voidisc_socket_ipv6only(isc_socket_t *sock, isc_boolean_t yes);/* * If the socket is an IPv6 socket set/clear the IPV6_IPV6ONLY socket * option if the host OS supports this option. * * Requires: * 'sock' is a valid socket. */ISC_LANG_ENDDECLS#endif /* ISC_SOCKET_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -