BLOG | DOCUMENTATION | GITHUB

Home --> Documentations --> PJLIB Reference

#include <ssl_sock.h>

Data Fields

pj_bool_t(* on_data_read )(pj_ssl_sock_t *ssock, void *data, pj_size_t size, pj_status_t status, pj_size_t *remainder)
 
pj_bool_t(* on_data_recvfrom )(pj_ssl_sock_t *ssock, 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_ssl_sock_t *ssock, pj_ioqueue_op_key_t *send_key, pj_ssize_t sent)
 
pj_bool_t(* on_accept_complete )(pj_ssl_sock_t *ssock, pj_ssl_sock_t *newsock, const pj_sockaddr_t *src_addr, int src_addr_len)
 
pj_bool_t(* on_accept_complete2 )(pj_ssl_sock_t *ssock, pj_ssl_sock_t *newsock, const pj_sockaddr_t *src_addr, int src_addr_len, pj_status_t status)
 
pj_bool_t(* on_connect_complete )(pj_ssl_sock_t *ssock, pj_status_t status)
 
pj_bool_t(* on_verify_cb )(pj_ssl_sock_t *ssock, pj_bool_t is_server)
 

Detailed Description

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

Field Documentation

◆ on_accept_complete

pj_bool_t(* pj_ssl_sock_cb::on_accept_complete) (pj_ssl_sock_t *ssock, pj_ssl_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_ssl_sock_start_accept(). If the status of accept operation is needed use on_accept_complete2 instead of this callback.

Parameters
ssockThe secure socket.
newsockThe new incoming secure 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 secure socket in the callback and return PJ_FALSE here.

◆ on_accept_complete2

pj_bool_t(* pj_ssl_sock_cb::on_accept_complete2) (pj_ssl_sock_t *ssock, pj_ssl_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_ssl_sock_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_ssl_sock_cb::on_connect_complete) (pj_ssl_sock_t *ssock, pj_status_t status)

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

Parameters
ssockThe secure socket.
statusThe connection result. If connection has been successfully established, the status will contain PJ_SUCCESS.
Returns
Application may destroy the secure socket in the callback and return PJ_FALSE here.

◆ on_data_read

pj_bool_t(* pj_ssl_sock_cb::on_data_read) (pj_ssl_sock_t *ssock, 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_ssl_sock_start_read().

Parameters
ssockThe secure 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 secure socket in the callback and return PJ_FALSE here.

◆ on_data_recvfrom

pj_bool_t(* pj_ssl_sock_cb::on_data_recvfrom) (pj_ssl_sock_t *ssock, 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_ssl_sock_start_recvfrom().

Parameters
ssockThe secure 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 secure socket in the callback and return PJ_FALSE here.

◆ on_data_sent

pj_bool_t(* pj_ssl_sock_cb::on_data_sent) (pj_ssl_sock_t *ssock, pj_ioqueue_op_key_t *send_key, pj_ssize_t sent)

This callback is called when data has been sent.

Parameters
ssockThe secure 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 secure socket in the callback and return PJ_FALSE here.

◆ on_verify_cb

pj_bool_t(* pj_ssl_sock_cb::on_verify_cb) (pj_ssl_sock_t *ssock, pj_bool_t is_server)

This callback is called when certificate verification is being done. Certification info can be obtained from pj_ssl_sock_info. Currently it's only implemented for OpenSSL backend.

Parameters
ssockThe secure socket.
is_serverPJ_TRUE to indicate an incoming connection.
Returns
Return PJ_TRUE if verification is successful. If verification failed, then the connection will be dropped immediately.

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.