⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ioqueue.h

📁 基于sip协议的网络电话源码
💻 H
📖 第 1 页 / 共 2 页
字号:
 * @return          PJ_SUCCESS on success or the error code. * * @see pj_ioqueue_is_pending */PJ_DECL(pj_status_t) pj_ioqueue_unregister( pj_ioqueue_key_t *key );/** * Get user data associated with an ioqueue key. * * @param key	    The key that was previously obtained from registration. * * @return          The user data associated with the descriptor, or NULL  *                  on error or if no data is associated with the key during *                  registration. */PJ_DECL(void*) pj_ioqueue_get_user_data( pj_ioqueue_key_t *key );/** * Set or change the user data to be associated with the file descriptor or * handle or socket descriptor. * * @param key	    The key that was previously obtained from registration. * @param user_data User data to be associated with the descriptor. * @param old_data  Optional parameter to retrieve the old user data. * * @return          PJ_SUCCESS on success or the error code. */PJ_DECL(pj_status_t) pj_ioqueue_set_user_data( pj_ioqueue_key_t *key,                                               void *user_data,                                               void **old_data);/** * Initialize operation key. * * @param op_key    The operation key to be initialied. * @param size	    The size of the operation key. */PJ_DECL(void) pj_ioqueue_op_key_init( pj_ioqueue_op_key_t *op_key,				      pj_size_t size );/** * Check if operation is pending on the specified operation key. * The \c op_key must have been initialized with #pj_ioqueue_op_key_init()  * or submitted as pending operation before, or otherwise the result  * is undefined. * * @param key       The key. * @param op_key    The operation key, previously submitted to any of *                  the I/O functions and has returned PJ_EPENDING. * * @return          Non-zero if operation is still pending. */PJ_DECL(pj_bool_t) pj_ioqueue_is_pending( pj_ioqueue_key_t *key,                                          pj_ioqueue_op_key_t *op_key );/** * Post completion status to the specified operation key and call the * appropriate callback. When the callback is called, the number of bytes  * received in read/write callback or the status in accept/connect callback * will be set from the \c bytes_status parameter. * * @param key           The key. * @param op_key        Pending operation key. * @param bytes_status  Number of bytes or status to be set. A good value *                      to put here is -PJ_ECANCELLED. * * @return              PJ_SUCCESS if completion status has been successfully *                      sent. */PJ_DECL(pj_status_t) pj_ioqueue_post_completion( pj_ioqueue_key_t *key,                                                 pj_ioqueue_op_key_t *op_key,                                                 pj_ssize_t bytes_status );#if defined(PJ_HAS_TCP) && PJ_HAS_TCP != 0/** * Instruct I/O Queue to accept incoming connection on the specified  * listening socket. This function will return immediately (i.e. non-blocking) * regardless whether a connection is immediately available. If the function * can't complete immediately, the caller will be notified about the incoming * connection when it calls pj_ioqueue_poll(). If a new connection is * immediately available, the function returns PJ_SUCCESS with the new * connection; in this case, the callback WILL NOT be called. * * @param key	    The key which registered to the server socket. * @param op_key    An operation specific key to be associated with the *                  pending operation, so that application can keep track of *                  which operation has been completed when the callback is *                  called. * @param new_sock  Argument which contain pointer to receive the new socket *                  for the incoming connection. * @param local	    Optional argument which contain pointer to variable to  *                  receive local address. * @param remote    Optional argument which contain pointer to variable to  *                  receive the remote address. * @param addrlen   On input, contains the length of the buffer for the *		    address, and on output, contains the actual length of the *		    address. This argument is optional. * @return *  - PJ_SUCCESS    When connection is available immediately, and the  *                  parameters will be updated to contain information about  *                  the new connection. In this case, a completion callback *                  WILL NOT be called. *  - PJ_EPENDING   If no connection is available immediately. When a new *                  connection arrives, the callback will be called. *  - non-zero      which indicates the appropriate error code. */PJ_DECL(pj_status_t) pj_ioqueue_accept( pj_ioqueue_key_t *key,                                        pj_ioqueue_op_key_t *op_key,					pj_sock_t *new_sock,					pj_sockaddr_t *local,					pj_sockaddr_t *remote,					int *addrlen );/** * Initiate non-blocking socket connect. If the socket can NOT be connected * immediately, asynchronous connect() will be scheduled and caller will be * notified via completion callback when it calls pj_ioqueue_poll(). If * socket is connected immediately, the function returns PJ_SUCCESS and * completion callback WILL NOT be called. * * @param key	    The key associated with TCP socket * @param addr	    The remote address. * @param addrlen   The remote address length. * * @return *  - PJ_SUCCESS    If socket is connected immediately. In this case, the *                  completion callback WILL NOT be called. *  - PJ_EPENDING   If operation is queued, or  *  - non-zero      Indicates the error code. */PJ_DECL(pj_status_t) pj_ioqueue_connect( pj_ioqueue_key_t *key,					 const pj_sockaddr_t *addr,					 int addrlen );#endif	/* PJ_HAS_TCP *//** * Poll the I/O Queue for completed events. * * @param ioque		the I/O Queue. * @param timeout	polling timeout, or NULL if the thread wishes to wait *			indefinetely for the event. * * @return  *  - zero if timed out (no event). *  - (<0) if error occured during polling. Callback will NOT be called. *  - (>1) to indicate numbers of events. Callbacks have been called. */PJ_DECL(int) pj_ioqueue_poll( pj_ioqueue_t *ioque,			      const pj_time_val *timeout);/** * Instruct the I/O Queue to read from the specified handle. This function * returns immediately (i.e. non-blocking) regardless whether some data has  * been transfered. If the operation can't complete immediately, caller will  * be notified about the completion when it calls pj_ioqueue_poll(). If data * is immediately available, the function will return PJ_SUCCESS and the * callback WILL NOT be called. * * @param key	    The key that uniquely identifies the handle. * @param op_key    An operation specific key to be associated with the *                  pending operation, so that application can keep track of *                  which operation has been completed when the callback is *                  called. Caller must make sure that this key remains  *                  valid until the function completes. * @param buffer    The buffer to hold the read data. The caller MUST make sure *		    that this buffer remain valid until the framework completes *		    reading the handle. * @param length    On input, it specifies the size of the buffer. If data is *                  available to be read immediately, the function returns *                  PJ_SUCCESS and this argument will be filled with the *                  amount of data read. If the function is pending, caller *                  will be notified about the amount of data read in the *                  callback. This parameter can point to local variable in *                  caller's stack and doesn't have to remain valid for the *                  duration of pending operation. * @param flags     Recv flag. If flags has PJ_IOQUEUE_ALWAYS_ASYNC then *		    the function will never return PJ_SUCCESS. * * @return *  - PJ_SUCCESS    If immediate data has been received in the buffer. In this *                  case, the callback WILL NOT be called. *  - PJ_EPENDING   If the operation has been queued, and the callback will be *                  called when data has been received. *  - non-zero      The return value indicates the error code. */PJ_DECL(pj_status_t) pj_ioqueue_recv( pj_ioqueue_key_t *key,                                      pj_ioqueue_op_key_t *op_key,				      void *buffer,				      pj_ssize_t *length,				      pj_uint32_t flags );/** * This function behaves similarly as #pj_ioqueue_recv(), except that it is * normally called for socket, and the remote address will also be returned * along with the data. Caller MUST make sure that both buffer and addr * remain valid until the framework completes reading the data. * * @param key	    The key that uniquely identifies the handle. * @param op_key    An operation specific key to be associated with the *                  pending operation, so that application can keep track of *                  which operation has been completed when the callback is *                  called. * @param buffer    The buffer to hold the read data. The caller MUST make sure *		    that this buffer remain valid until the framework completes *		    reading the handle. * @param length    On input, it specifies the size of the buffer. If data is *                  available to be read immediately, the function returns *                  PJ_SUCCESS and this argument will be filled with the *                  amount of data read. If the function is pending, caller *                  will be notified about the amount of data read in the *                  callback. This parameter can point to local variable in *                  caller's stack and doesn't have to remain valid for the *                  duration of pending operation. * @param flags     Recv flag. If flags has PJ_IOQUEUE_ALWAYS_ASYNC then *		    the function will never return PJ_SUCCESS. * @param addr      Optional Pointer to buffer to receive the address. * @param addrlen   On input, specifies the length of the address buffer. *                  On output, it will be filled with the actual length of *                  the address. This argument can be NULL if \c addr is not *                  specified. * * @return *  - PJ_SUCCESS    If immediate data has been received. In this case, the  *		    callback must have been called before this function  *		    returns, and no pending operation is scheduled. *  - PJ_EPENDING   If the operation has been queued. *  - non-zero      The return value indicates the error code. */PJ_DECL(pj_status_t) pj_ioqueue_recvfrom( pj_ioqueue_key_t *key,                                          pj_ioqueue_op_key_t *op_key,					  void *buffer,					  pj_ssize_t *length,                                          pj_uint32_t flags,					  pj_sockaddr_t *addr,					  int *addrlen);/** * Instruct the I/O Queue to write to the handle. This function will return * immediately (i.e. non-blocking) regardless whether some data has been  * transfered. If the function can't complete immediately, the caller will * be notified about the completion when it calls pj_ioqueue_poll(). If  * operation completes immediately and data has been transfered, the function * returns PJ_SUCCESS and the callback will NOT be called. * * @param key	    The key that identifies the handle. * @param op_key    An operation specific key to be associated with the *                  pending operation, so that application can keep track of *                  which operation has been completed when the callback is *                  called. * @param data	    The data to send. Caller MUST make sure that this buffer  *		    remains valid until the write operation completes. * @param length    On input, it specifies the length of data to send. When *                  data was sent immediately, this function returns PJ_SUCCESS *                  and this parameter contains the length of data sent. If *                  data can not be sent immediately, an asynchronous operation *                  is scheduled and caller will be notified via callback the *                  number of bytes sent. This parameter can point to local  *                  variable on caller's stack and doesn't have to remain  *                  valid until the operation has completed. * @param flags     Send flags. If flags has PJ_IOQUEUE_ALWAYS_ASYNC then *		    the function will never return PJ_SUCCESS. * * @return *  - PJ_SUCCESS    If data was immediately transfered. In this case, no *                  pending operation has been scheduled and the callback *                  WILL NOT be called. *  - PJ_EPENDING   If the operation has been queued. Once data base been *                  transfered, the callback will be called. *  - non-zero      The return value indicates the error code. */PJ_DECL(pj_status_t) pj_ioqueue_send( pj_ioqueue_key_t *key,                                      pj_ioqueue_op_key_t *op_key,				      const void *data,				      pj_ssize_t *length,				      pj_uint32_t flags );/** * Instruct the I/O Queue to write to the handle. This function will return * immediately (i.e. non-blocking) regardless whether some data has been  * transfered. If the function can't complete immediately, the caller will * be notified about the completion when it calls pj_ioqueue_poll(). If  * operation completes immediately and data has been transfered, the function * returns PJ_SUCCESS and the callback will NOT be called. * * @param key	    the key that identifies the handle. * @param op_key    An operation specific key to be associated with the *                  pending operation, so that application can keep track of *                  which operation has been completed when the callback is *                  called. * @param data	    the data to send. Caller MUST make sure that this buffer  *		    remains valid until the write operation completes. * @param length    On input, it specifies the length of data to send. When *                  data was sent immediately, this function returns PJ_SUCCESS *                  and this parameter contains the length of data sent. If *                  data can not be sent immediately, an asynchronous operation *                  is scheduled and caller will be notified via callback the *                  number of bytes sent. This parameter can point to local  *                  variable on caller's stack and doesn't have to remain  *                  valid until the operation has completed. * @param flags     send flags. If flags has PJ_IOQUEUE_ALWAYS_ASYNC then *		    the function will never return PJ_SUCCESS. * @param addr      Optional remote address. * @param addrlen   Remote address length, \c addr is specified. * * @return *  - PJ_SUCCESS    If data was immediately written. *  - PJ_EPENDING   If the operation has been queued. *  - non-zero      The return value indicates the error code. */PJ_DECL(pj_status_t) pj_ioqueue_sendto( pj_ioqueue_key_t *key,                                        pj_ioqueue_op_key_t *op_key,					const void *data,					pj_ssize_t *length,                                        pj_uint32_t flags,					const pj_sockaddr_t *addr,					int addrlen);/** * !} */PJ_END_DECL#endif	/* __PJ_IOQUEUE_H__ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -