Go to the source code of this file.
|
STATUS | createSocketConnection (KVS_IP_FAMILY_TYPE, KVS_SOCKET_PROTOCOL, PKvsIpAddress, PKvsIpAddress, UINT64, ConnectionDataAvailableFunc, UINT32, PSocketConnection *) |
|
STATUS | freeSocketConnection (PSocketConnection *) |
|
STATUS | socketConnectionInitSecureConnection (PSocketConnection, BOOL) |
|
STATUS | socketConnectionSendData (PSocketConnection, PBYTE, UINT32, PKvsIpAddress) |
|
STATUS | socketConnectionReadData (PSocketConnection, PBYTE, UINT32, PUINT32) |
|
STATUS | socketConnectionClosed (PSocketConnection) |
|
BOOL | socketConnectionIsClosed (PSocketConnection) |
|
BOOL | socketConnectionIsConnected (PSocketConnection) |
|
STATUS | socketSendDataWithRetry (PSocketConnection, PBYTE, UINT32, PKvsIpAddress, PUINT32) |
|
STATUS | socketConnectionTlsSessionOutBoundPacket (UINT64, PBYTE, UINT32) |
|
VOID | socketConnectionTlsSessionOnStateChange (UINT64, TLS_SESSION_STATE) |
|
◆ CLOSE_SOCKET_IF_CANT_RETRY
#define CLOSE_SOCKET_IF_CANT_RETRY |
( |
|
e, |
|
|
|
ps |
|
) |
| |
Value: if ((e) != EAGAIN && (e) != EWOULDBLOCK && (e) != EINTR && (e) != EINPROGRESS && (e) != EPERM && (e) != EALREADY && (e) != ENETUNREACH) { \
DLOGD("Close socket %d", (ps)->localSocket); \
ATOMIC_STORE_BOOL(&(ps)->connectionClosed, TRUE); \
}
◆ MAX_SOCKET_WRITE_RETRY
#define MAX_SOCKET_WRITE_RETRY 3 |
◆ SOCKET_SEND_RETRY_TIMEOUT_MILLI_SECOND
#define SOCKET_SEND_RETRY_TIMEOUT_MILLI_SECOND 500 |
◆ ConnectionDataAvailableFunc
◆ PSocketConnection
◆ SocketConnection
◆ createSocketConnection()
Create a SocketConnection object and store it in PSocketConnection. creates a socket based on KVS_SOCKET_PROTOCOL specified, and bind it to the host ip address. If the protocol is tcp, then peer ip address is required and it will try to establish the tcp connection.
- Parameters
-
- | KVS_IP_FAMILY_TYPE - IN - Family for the socket. Must be one of KVS_IP_FAMILY_TYPE |
- | KVS_SOCKET_PROTOCOL - IN - socket protocol. TCP or UDP |
- | PKvsIpAddress - IN - host ip address to bind to (OPTIONAL) |
- | PKvsIpAddress - IN - peer ip address to connect in case of TCP (OPTIONAL) |
- | UINT64 - IN - data available callback custom data |
- | ConnectionDataAvailableFunc - IN - data available callback (OPTIONAL) |
- | UINT32 - IN - send buffer size in bytes |
- | PSocketConnection* - OUT - the resulting SocketConnection struct |
- Returns
- - STATUS - status of execution
◆ freeSocketConnection()
Free the SocketConnection struct
- Parameters
-
- | PSocketConnection* - IN - SocketConnection to be freed |
- Returns
- - STATUS - status of execution
◆ socketConnectionClosed()
Mark PSocketConnection as closed
- Parameters
-
- | PSocketConnection - IN - the SocketConnection struct |
- Returns
- - STATUS - status of execution
◆ socketConnectionInitSecureConnection()
STATUS socketConnectionInitSecureConnection |
( |
PSocketConnection |
pSocketConnection, |
|
|
BOOL |
isServer |
|
) |
| |
Given a created SocketConnection, initialize TLS or DTLS handshake depending on the socket protocol
- Parameters
-
- | PSocketConnection - IN - the SocketConnection struct |
- | BOOL - IN - will SocketConnection act as server during the TLS or DTLS handshake |
- Returns
- - STATUS - status of execution
◆ socketConnectionIsClosed()
Check if PSocketConnection is closed
- Parameters
-
- | PSocketConnection - IN - the SocketConnection struct |
- Returns
- - BOOL - whether connection is closed
◆ socketConnectionIsConnected()
Return whether socket has been connected. Return TRUE for UDP sockets. Return TRUE for TCP sockets once the connection has been established, otherwise return FALSE.
- Parameters
-
- | PSocketConnection - IN - the SocketConnection struct |
- Returns
- - STATUS - status of execution
◆ socketConnectionReadData()
STATUS socketConnectionReadData |
( |
PSocketConnection |
pSocketConnection, |
|
|
PBYTE |
pBuf, |
|
|
UINT32 |
bufferLen, |
|
|
PUINT32 |
pDataLen |
|
) |
| |
If PSocketConnection is not secure then nothing happens, otherwise assuming the bytes passed in are encrypted, and the encryted data will be replaced with unencrypted data at function return.
- Parameters
-
- | PSocketConnection - IN - the SocketConnection struct |
- | PBYTE - IN/OUT - buffer containing encrypted data. Will contain unencrypted on successful return |
- | UINT32 - IN - available length of buffer |
- | PUINT32 - IN/OUT - length of encrypted data. Will contain length of decrypted data on successful return |
- Returns
- - STATUS - status of execution
◆ socketConnectionSendData()
Given a created SocketConnection, send data through the underlying socket. If socket type is UDP, then destination address is required. If socket type is tcp, destination address is ignored and data is send to the peer address provided at SocketConnection creation. If socketConnectionInitSecureConnection has been called then data will be encrypted, otherwise data will be sent as is.
- Parameters
-
- | PSocketConnection - IN - the SocketConnection struct |
- | PBYTE - IN - buffer containing unencrypted data |
- | UINT32 - IN - length of buffer |
- | PKvsIpAddress - IN - destination address. Required only if socket type is UDP. |
- Returns
- - STATUS - status of execution
◆ socketConnectionTlsSessionOnStateChange()
VOID socketConnectionTlsSessionOnStateChange |
( |
UINT64 |
customData, |
|
|
TLS_SESSION_STATE |
state |
|
) |
| |
◆ socketConnectionTlsSessionOutBoundPacket()
STATUS socketConnectionTlsSessionOutBoundPacket |
( |
UINT64 |
customData, |
|
|
PBYTE |
pBuffer, |
|
|
UINT32 |
bufferLen |
|
) |
| |
◆ socketSendDataWithRetry()