#include "../Include_i.h"
Macros | |
#define | LOG_CLASS "SocketConnection" |
Functions | |
STATUS | createSocketConnection (KVS_IP_FAMILY_TYPE familyType, KVS_SOCKET_PROTOCOL protocol, PKvsIpAddress pBindAddr, PKvsIpAddress pPeerIpAddr, UINT64 customData, ConnectionDataAvailableFunc dataAvailableFn, UINT32 sendBufSize, PSocketConnection *ppSocketConnection) |
STATUS | freeSocketConnection (PSocketConnection *ppSocketConnection) |
STATUS | socketConnectionTlsSessionOutBoundPacket (UINT64 customData, PBYTE pBuffer, UINT32 bufferLen) |
VOID | socketConnectionTlsSessionOnStateChange (UINT64 customData, TLS_SESSION_STATE state) |
STATUS | socketConnectionInitSecureConnection (PSocketConnection pSocketConnection, BOOL isServer) |
STATUS | socketConnectionSendData (PSocketConnection pSocketConnection, PBYTE pBuf, UINT32 bufLen, PKvsIpAddress pDestIp) |
STATUS | socketConnectionReadData (PSocketConnection pSocketConnection, PBYTE pBuf, UINT32 bufferLen, PUINT32 pDataLen) |
STATUS | socketConnectionClosed (PSocketConnection pSocketConnection) |
BOOL | socketConnectionIsClosed (PSocketConnection pSocketConnection) |
BOOL | socketConnectionIsConnected (PSocketConnection pSocketConnection) |
STATUS | socketSendDataWithRetry (PSocketConnection pSocketConnection, PBYTE buf, UINT32 bufLen, PKvsIpAddress pDestIp, PUINT32 pBytesWritten) |
#define LOG_CLASS "SocketConnection" |
Kinesis Video Tcp
STATUS createSocketConnection | ( | KVS_IP_FAMILY_TYPE | familyType, |
KVS_SOCKET_PROTOCOL | protocol, | ||
PKvsIpAddress | pBindAddr, | ||
PKvsIpAddress | pPeerIpAddr, | ||
UINT64 | customData, | ||
ConnectionDataAvailableFunc | dataAvailableFn, | ||
UINT32 | sendBufSize, | ||
PSocketConnection * | ppSocketConnection | ||
) |
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.
- | 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 |
STATUS freeSocketConnection | ( | PSocketConnection * | ppSocketConnection | ) |
Free the SocketConnection struct
- | PSocketConnection* - IN - SocketConnection to be freed |
STATUS socketConnectionClosed | ( | PSocketConnection | pSocketConnection | ) |
Mark PSocketConnection as closed
- | PSocketConnection - IN - the SocketConnection struct |
STATUS socketConnectionInitSecureConnection | ( | PSocketConnection | pSocketConnection, |
BOOL | isServer | ||
) |
Given a created SocketConnection, initialize TLS or DTLS handshake depending on the socket protocol
- | PSocketConnection - IN - the SocketConnection struct |
- | BOOL - IN - will SocketConnection act as server during the TLS or DTLS handshake |
BOOL socketConnectionIsClosed | ( | PSocketConnection | pSocketConnection | ) |
Check if PSocketConnection is closed
- | PSocketConnection - IN - the SocketConnection struct |
BOOL socketConnectionIsConnected | ( | PSocketConnection | pSocketConnection | ) |
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.
- | PSocketConnection - IN - the SocketConnection struct |
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.
- | 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 |
STATUS socketConnectionSendData | ( | PSocketConnection | pSocketConnection, |
PBYTE | pBuf, | ||
UINT32 | bufLen, | ||
PKvsIpAddress | pDestIp | ||
) |
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.
- | 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. |
VOID socketConnectionTlsSessionOnStateChange | ( | UINT64 | customData, |
TLS_SESSION_STATE | state | ||
) |
STATUS socketConnectionTlsSessionOutBoundPacket | ( | UINT64 | customData, |
PBYTE | pBuffer, | ||
UINT32 | bufferLen | ||
) |
STATUS socketSendDataWithRetry | ( | PSocketConnection | pSocketConnection, |
PBYTE | buf, | ||
UINT32 | bufLen, | ||
PKvsIpAddress | pDestIp, | ||
PUINT32 | pBytesWritten | ||
) |