Manage network sockets and connections. More...
#include <sock.hpp>
#include <upnp.hpp>
#include <UPnPsdk/connection_common.hpp>
#include <UPnPsdk/socket.hpp>
#include <umock/sys_socket.hpp>
#include <umock/ssl.hpp>
Go to the source code of this file.
Functions | |
int | sock_init (SOCKINFO *info, SOCKET sockfd) |
Assign the passed in socket descriptor to socket descriptor in the SOCKINFO structure. | |
int | sock_init_with_ip (SOCKINFO *info, SOCKET sockfd, sockaddr *foreign_sockaddr) |
Calls the sock_init function and assigns the passed in IP address and port to the IP address and port in the SOCKINFO structure. | |
int | sock_ssl_connect (SOCKINFO *info) |
Associates an SSL object with the socket and begins the client-side SSL/TLS handshake. | |
int | sock_destroy (SOCKINFO *info, int ShutdownMethod) |
Shutsdown the socket using the ShutdownMethod to indicate whether sends and receives on the socket will be dis-allowed. | |
int | sock_read (SOCKINFO *info, char *buffer, size_t bufsize, int *timeoutSecs) |
Reads data on socket in sockinfo. | |
int | sock_write (SOCKINFO *info, const char *buffer, size_t bufsize, int *timeoutSecs) |
Writes data on the socket in sockinfo. | |
int | sock_make_blocking (SOCKET sock) |
Make socket blocking. | |
int | sock_make_no_blocking (SOCKET sock) |
Make socket non-blocking. | |
int | UpnpInitSslContext (int initOpenSslLib, const SSL_METHOD *sslMethod) |
Initializes the OpenSSL library, and the OpenSSL context. | |
void | freeSslCtx () |
Free the OpenSSL context. | |
Scope restricted to file | |
int | anonymous_namespace{sock.cpp}::sock_read_unprotected (const SOCKINFO *a_info, char *a_readbuf, const char *a_writebuf, const size_t a_bufsize, int *a_timeoutSecs) |
Read from a not SSL protected socket. | |
int | anonymous_namespace{sock.cpp}::sock_write_unprotected (const SOCKINFO *a_info, char *a_readbuf, const char *a_writebuf, const size_t a_bufsize, int *a_timeoutSecs) |
Write to a not SSL protected socket. | |
int | anonymous_namespace{sock.cpp}::sock_read_ssl (const SOCKINFO *a_info, char *a_readbuf, const char *a_writebuf, const size_t a_bufsize, int *a_timeoutSecs) |
Read from an SSL protected socket. | |
int | anonymous_namespace{sock.cpp}::sock_write_ssl (const SOCKINFO *a_info, char *a_readbuf, const char *a_writebuf, const size_t a_bufsize, int *a_timeoutSecs) |
Write to an SSL protected socket. | |
Variables | |
SSL_CTX * | anonymous_namespace{sock.cpp}::gSslCtx {nullptr} |
Pointer to an SSL Context. | |
Manage network sockets and connections.
Definition in file sock.cpp.
int sock_init | ( | SOCKINFO * | info, |
SOCKET | sockfd | ||
) |
Assign the passed in socket descriptor to socket descriptor in the SOCKINFO structure.
UPNP_E_SUCCESS
UPNP_E_OUTOF_MEMORY
UPNP_E_SOCKET_ERROR
[out] | info | Socket Information Object. |
[in] | sockfd | Socket Descriptor. |
Definition at line 440 of file sock.cpp.
int sock_init_with_ip | ( | SOCKINFO * | info, |
SOCKET | sockfd, | ||
struct sockaddr * | foreign_sockaddr | ||
) |
Calls the sock_init function and assigns the passed in IP address and port to the IP address and port in the SOCKINFO structure.
UPNP_E_SUCCESS
UPNP_E_OUTOF_MEMORY
UPNP_E_SOCKET_ERROR
[out] | info | Socket Information Object. |
[in] | sockfd | Socket Descriptor. |
[in] | foreign_sockaddr | Remote socket address. |
Definition at line 451 of file sock.cpp.
int sock_ssl_connect | ( | SOCKINFO * | info | ) |
int sock_destroy | ( | SOCKINFO * | info, |
int | ShutdownMethod | ||
) |
Shutsdown the socket using the ShutdownMethod to indicate whether sends and receives on the socket will be dis-allowed.
After shutting down the socket, closesocket is called to release system resources used by the socket calls.
UPNP_E_SOCKET_ERROR
on failure. UPNP_E_SUCCESS
on success. [in,out] | info | Socket Information Object. |
[in] | ShutdownMethod | How to shutdown the socket. Used by sockets's shutdown(). |
Definition at line 489 of file sock.cpp.
int sock_read | ( | SOCKINFO * | info, |
char * | buffer, | ||
size_t | bufsize, | ||
int * | timeoutSecs | ||
) |
Reads data on socket in sockinfo.
numBytes
- On Success, no of bytes received. UPNP_E_TIMEDOUT
- Timeout. UPNP_E_SOCKET_ERROR
- Error on socket calls. [in] | info | Socket Information Object. |
[out] | buffer | Buffer to get data to. |
[in] | bufsize | Size of the buffer. |
[in,out] | timeoutSecs | timeout value. |
Definition at line 525 of file sock.cpp.
int sock_write | ( | SOCKINFO * | info, |
const char * | buffer, | ||
size_t | bufsize, | ||
int * | timeoutSecs | ||
) |
Writes data on the socket in sockinfo.
numBytes
- On Success, no of bytes sent. UPNP_E_TIMEDOUT
- Timeout. UPNP_E_SOCKET_ERROR
- Error on socket calls. [in] | info | Socket Information Object. |
[in] | buffer | Buffer to send data from. |
[in] | bufsize | Size of the buffer. |
[in,out] | timeoutSecs | timeout value. |
Definition at line 541 of file sock.cpp.
int sock_make_blocking | ( | SOCKET | sock | ) |
int sock_make_no_blocking | ( | SOCKET | sock | ) |