WARNING: The online documentation has moved to https://docs.pjsip.org.

Visit the new documentation at https://docs.pjsip.org:

BLOG | DOCUMENTATION | GITHUB

Home --> Documentations --> PJLIB Reference

pj_activesock_cb Struct Reference
[Active socket I/O]

Data Fields

pj_bool_t(* on_data_read )(pj_activesock_t *asock, void *data, pj_size_t size, pj_status_t status, pj_size_t *remainder)
pj_bool_t(* on_data_recvfrom )(pj_activesock_t *asock, void *data, pj_size_t size, const pj_sockaddr_t *src_addr, int addr_len, pj_status_t status)
pj_bool_t(* on_data_sent )(pj_activesock_t *asock, pj_ioqueue_op_key_t *send_key, pj_ssize_t sent)
pj_bool_t(* on_accept_complete )(pj_activesock_t *asock, pj_sock_t newsock, const pj_sockaddr_t *src_addr, int src_addr_len)
pj_bool_t(* on_connect_complete )(pj_activesock_t *asock, pj_status_t status)

Detailed Description

This structure contains the callbacks to be called by the active socket.


Field Documentation

pj_bool_t(* pj_activesock_cb::on_accept_complete)(pj_activesock_t *asock, pj_sock_t newsock, const pj_sockaddr_t *src_addr, int src_addr_len)

This callback is called when new connection arrives as the result of pj_activesock_start_accept().

Parameters:
asock The active socket.
newsock The new incoming socket.
src_addr The source address of the connection.
addr_len Length of the source address.
Returns:
PJ_TRUE if further accept() is desired, and PJ_FALSE when application no longer wants to accept incoming connection. Application may destroy the active socket in the callback and return PJ_FALSE here.

This callback is called when pending connect operation has been completed.

Parameters:
asock The active socket.
status The connection result. If connection has been successfully established, the status will contain PJ_SUCCESS.
Returns:
Application may destroy the active socket in the callback and return PJ_FALSE here.
pj_bool_t(* pj_activesock_cb::on_data_read)(pj_activesock_t *asock, void *data, pj_size_t size, pj_status_t status, pj_size_t *remainder)

This callback is called when a data arrives as the result of pj_activesock_start_read().

Parameters:
asock The active socket.
data The buffer containing the new data, if any. If the status argument is non-PJ_SUCCESS, this argument may be NULL.
size The length of data in the buffer.
status The status of the read operation. This may contain non-PJ_SUCCESS for example when the TCP connection has been closed. In this case, the buffer may contain left over data from previous callback which the application may want to process.
remainder If application wishes to leave some data in the buffer (common for TCP applications), it should move the remainder data to the front part of the buffer and set the remainder length here. The value of this parameter will be ignored for datagram sockets.
Returns:
PJ_TRUE if further read is desired, and PJ_FALSE when application no longer wants to receive data. Application may destroy the active socket in the callback and return PJ_FALSE here.
pj_bool_t(* pj_activesock_cb::on_data_recvfrom)(pj_activesock_t *asock, void *data, pj_size_t size, const pj_sockaddr_t *src_addr, int addr_len, pj_status_t status)

This callback is called when a packet arrives as the result of pj_activesock_start_recvfrom().

Parameters:
asock The active socket.
data The buffer containing the packet, if any. If the status argument is non-PJ_SUCCESS, this argument will be set to NULL.
size The length of packet in the buffer. If the status argument is non-PJ_SUCCESS, this argument will be set to zero.
src_addr Source address of the packet.
addr_len Length of the source address.
status This contains
Returns:
PJ_TRUE if further read is desired, and PJ_FALSE when application no longer wants to receive data. Application may destroy the active socket in the callback and return PJ_FALSE here.

This callback is called when data has been sent.

Parameters:
asock The active socket.
send_key Key associated with the send operation.
sent If value is positive non-zero it indicates the number of data sent. When the value is negative, it contains the error code which can be retrieved by negating the value (i.e. status=-sent).
Returns:
Application may destroy the active socket in the callback and return PJ_FALSE here.

The documentation for this struct was generated from the following file:

 


PJLIB Open Source, high performance, small footprint, and very very portable framework
Copyright (C) 2006-2009 Teluu Inc.