Network stream client functions. (TCP). More...
#include "nets/socket.h"Typedefs | |
| typedef struct StreamClient_T | StreamClient_T |
| typedef StreamClient_T * | StreamClient |
| typedef void(* | OnStreamClientConnection) (StreamClient streamClient, NetsResult result) |
| Stream client connection result function. (TCP). | |
| typedef void(* | OnStreamClientDisconnect) (StreamClient streamClient, int reason) |
| Stream client on server disconnect function. (TCP). | |
| typedef int(* | OnStreamClientReceive) (StreamClient streamClient, const uint8_t *receiveBuffer, size_t byteCount) |
| Stream client data receive function. (TCP). | |
| typedef int(* | OnStreamClientDatagram) (StreamClient streamClient, const uint8_t *receiveBuffer, size_t byteCount) |
| Stream client datagram receive function. (UDP). | |
Functions | |
| NetsResult | createStreamClient (size_t bufferSize, double timeoutTime, OnStreamClientConnection onConnection, OnStreamClientDisconnect onDisconnect, OnStreamClientReceive onReceive, OnStreamClientDatagram onDatagram, void *handle, SslContext sslContext, StreamClient *streamClient) |
| Creates a new stream client instance. (TCP). | |
| void | destroyStreamClient (StreamClient streamClient) |
| Destroys stream client instance. (TCP). | |
| size_t | getStreamClientBufferSize (StreamClient streamClient) |
| Returns stream client receive buffer size in bytes. | |
| double | getStreamClientTimeoutTime (StreamClient streamClient) |
| Returns stream client server timeout time. (in seconds). | |
| OnStreamClientConnection | getStreamClientOnConnection (StreamClient streamClient) |
| Returns stream client connection result function. | |
| OnStreamClientReceive | getStreamClientOnReceive (StreamClient streamClient) |
| Returns stream client data receive function. | |
| OnStreamClientDatagram | getStreamClientOnDatagram (StreamClient streamClient) |
| Returns stream client datagram receive function. | |
| void * | getStreamClientHandle (StreamClient streamClient) |
| Returns stream client handle. | |
| uint8_t * | getStreamClientBuffer (StreamClient streamClient) |
| Returns stream client data buffer. | |
| SslContext | getStreamClientSslContext (StreamClient streamClient) |
| Returns stream client socket SSL context instance. | |
| void | setStreamClientSslContext (StreamClient streamClient, SslContext sslContext) |
| Sets stream client socket SSL context instance. | |
| bool | isStreamClientSecure (StreamClient streamClient) |
| Returns true if stream client use encrypted connection. | |
| bool | isStreamClientRunning (StreamClient streamClient) |
| Returns true if stream client receive thread is running. (MT-Safe). | |
| bool | isStreamClientConnected (StreamClient streamClient) |
| Returns true if stream client is connected to the server. (MT-Safe). | |
| NetsResult | connectStreamClientByAddress (StreamClient streamClient, SocketAddress remoteAddress, const char *hostname) |
| Initiates stream client connection to the server with specified IP address. | |
| NetsResult | connectStreamClientByHostname (StreamClient streamClient, const char *hostname, const char *service, bool setSNI) |
| Initiates stream client connection to the server with specified hostname and service. | |
| void | disconnectStreamClient (StreamClient streamClient) |
| Disconnects stream client from the server. | |
| void | updateStreamClient (StreamClient streamClient) |
| Updates stream client state. | |
| void | aliveStreamClient (StreamClient streamClient) |
| Resets stream client server timeout time. | |
| NetsResult | streamClientSend (StreamClient streamClient, const void *data, size_t byteCount) |
| Sends stream data to the server. (TCP). | |
| NetsResult | streamClientSendDatagram (StreamClient streamClient, const void *data, size_t byteCount) |
| Sends datagram to the server. (UDP). | |
Network stream client functions. (TCP).
| typedef struct StreamClient_T StreamClient_T |
Stream client structure. (TCP)
| typedef StreamClient_T* StreamClient |
Stream client instance. (TCP)
| typedef void(* OnStreamClientConnection) (StreamClient streamClient, NetsResult result) |
Stream client connection result function. (TCP).
| streamClient | stream client instance |
| result | connection to the server result |
| typedef void(* OnStreamClientDisconnect) (StreamClient streamClient, int reason) |
Stream client on server disconnect function. (TCP).
| streamClient | stream client instance |
| reason | server disconnection reason |
| typedef int(* OnStreamClientReceive) (StreamClient streamClient, const uint8_t *receiveBuffer, size_t byteCount) |
Stream client data receive function. (TCP).
Client stops receive thread on this function non zero return result.
| streamClient | stream client instance | |
| [in] | receiveBuffer | received data buffer |
| byteCount | received byte count |
| typedef int(* OnStreamClientDatagram) (StreamClient streamClient, const uint8_t *receiveBuffer, size_t byteCount) |
Stream client datagram receive function. (UDP).
Client stops receive thread on this function non zero return result.
| streamClient | stream client instance | |
| [in] | receiveBuffer | received data buffer |
| byteCount | received byte count |
| NetsResult createStreamClient | ( | size_t | bufferSize, |
| double | timeoutTime, | ||
| OnStreamClientConnection | onConnection, | ||
| OnStreamClientDisconnect | onDisconnect, | ||
| OnStreamClientReceive | onReceive, | ||
| OnStreamClientDatagram | onDatagram, | ||
| void * | handle, | ||
| SslContext | sslContext, | ||
| StreamClient * | streamClient ) |
Creates a new stream client instance. (TCP).
| bufferSize | receive data buffer size in bytes | |
| timeoutTime | server timeout time in seconds | |
| [in] | onConnection | on connection result function |
| [in] | onDisconnect | on server disconnect function |
| [in] | onReceive | on data receive function |
| [in] | onDatagram | on datagrtam receive function or NULL |
| [in] | handle | receive function argument or NULL |
| sslContext | socket SSL context instance or NULL | |
| [out] | streamClient | pointer to the stream client instance |
| void destroyStreamClient | ( | StreamClient | streamClient | ) |
Destroys stream client instance. (TCP).
| streamClient | target stream client instance or NULL |
| size_t getStreamClientBufferSize | ( | StreamClient | streamClient | ) |
Returns stream client receive buffer size in bytes.
| streamClient | target stream client instance |
| double getStreamClientTimeoutTime | ( | StreamClient | streamClient | ) |
Returns stream client server timeout time. (in seconds).
| streamClient | target stream client instance |
| OnStreamClientConnection getStreamClientOnConnection | ( | StreamClient | streamClient | ) |
Returns stream client connection result function.
| streamClient | target stream client instance |
| OnStreamClientReceive getStreamClientOnReceive | ( | StreamClient | streamClient | ) |
Returns stream client data receive function.
| streamClient | target stream client instance |
| OnStreamClientDatagram getStreamClientOnDatagram | ( | StreamClient | streamClient | ) |
Returns stream client datagram receive function.
| streamClient | target stream client instance |
| void * getStreamClientHandle | ( | StreamClient | streamClient | ) |
Returns stream client handle.
| streamClient | target stream client instance |
| uint8_t * getStreamClientBuffer | ( | StreamClient | streamClient | ) |
Returns stream client data buffer.
| streamClient | target stream client instance |
| SslContext getStreamClientSslContext | ( | StreamClient | streamClient | ) |
Returns stream client socket SSL context instance.
| streamClient | target stream client instance |
| void setStreamClientSslContext | ( | StreamClient | streamClient, |
| SslContext | sslContext ) |
Sets stream client socket SSL context instance.
| streamClient | target stream client instance |
| sslContext | socket SSL context instance or NULL |
| bool isStreamClientSecure | ( | StreamClient | streamClient | ) |
Returns true if stream client use encrypted connection.
| streamClient | target stream client instance |
| bool isStreamClientRunning | ( | StreamClient | streamClient | ) |
Returns true if stream client receive thread is running. (MT-Safe).
| streamClient | target stream client instance |
| bool isStreamClientConnected | ( | StreamClient | streamClient | ) |
Returns true if stream client is connected to the server. (MT-Safe).
| streamClient | target stream client instance |
| NetsResult connectStreamClientByAddress | ( | StreamClient | streamClient, |
| SocketAddress | remoteAddress, | ||
| const char * | hostname ) |
Initiates stream client connection to the server with specified IP address.
| streamClient | target stream client instance | |
| remoteAddress | remote server IP address | |
| [in] | hostname | remote server hostname or NULL |
| NetsResult connectStreamClientByHostname | ( | StreamClient | streamClient, |
| const char * | hostname, | ||
| const char * | service, | ||
| bool | setSNI ) |
Initiates stream client connection to the server with specified hostname and service.
| streamClient | target stream client instance | |
| [in] | hostname | server hostname string |
| [in] | service | server service string (port) |
| setSNI | set SSL server SNI hostname |
| void disconnectStreamClient | ( | StreamClient | streamClient | ) |
Disconnects stream client from the server.
| streamClient | target stream client instance |
| void updateStreamClient | ( | StreamClient | streamClient | ) |
Updates stream client state.
| streamClient | target stream client instance |
| void aliveStreamClient | ( | StreamClient | streamClient | ) |
Resets stream client server timeout time.
| streamClient | target stream client instance |
| NetsResult streamClientSend | ( | StreamClient | streamClient, |
| const void * | data, | ||
| size_t | byteCount ) |
Sends stream data to the server. (TCP).
Internally synchronized. (MT-Safe)
| streamClient | target stream client instance | |
| [in] | data | data send buffer |
| byteCount | data byte count to send |
| NetsResult streamClientSendDatagram | ( | StreamClient | streamClient, |
| const void * | data, | ||
| size_t | byteCount ) |
Sends datagram to the server. (UDP).
Internally synchronized. (MT-Safe)
| streamClient | target stream client instance | |
| [in] | data | send data buffer |
| byteCount | data byte count to send |