BLOG | DOCUMENTATION | TRAC

Home --> Documentations --> PJLIB Reference

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_accept_complete2 )(pj_activesock_t *asock, pj_sock_t newsock, const pj_sockaddr_t *src_addr, int src_addr_len, pj_status_t status)
 
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

◆ on_accept_complete

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(). If the status of accept operation is needed use on_accept_complete2 instead of this callback.

Parameters
asockThe active socket.
newsockThe new incoming socket.
src_addrThe source address of the connection.
addr_lenLength 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.

◆ on_accept_complete2

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

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

Parameters
asockThe active socket.
newsockThe new incoming socket.
src_addrThe source address of the connection.
addr_lenLength of the source address.
statusThe status of the accept operation. This may contain non-PJ_SUCCESS for example when the TCP listener is in bad state for example on iOS platform after the application waking up from background.
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.

◆ on_connect_complete

pj_bool_t(* pj_activesock_cb::on_connect_complete) (pj_activesock_t *asock, pj_status_t status)

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

Parameters
asockThe active socket.
statusThe 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.

◆ on_data_read

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
asockThe active socket.
dataThe buffer containing the new data, if any. If the status argument is non-PJ_SUCCESS, this argument may be NULL.
sizeThe length of data in the buffer.
statusThe 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.
remainderIf 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.

◆ on_data_recvfrom

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
asockThe active socket.
dataThe buffer containing the packet, if any. If the status argument is non-PJ_SUCCESS, this argument will be set to NULL.
sizeThe length of packet in the buffer. If the status argument is non-PJ_SUCCESS, this argument will be set to zero.
src_addrSource address of the packet.
addr_lenLength of the source address.
statusThis 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.

◆ on_data_sent

pj_bool_t(* pj_activesock_cb::on_data_sent) (pj_activesock_t *asock, pj_ioqueue_op_key_t *send_key, pj_ssize_t sent)

This callback is called when data has been sent.

Parameters
asockThe active socket.
send_keyKey associated with the send operation.
sentIf 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.