2#ifndef INTERFACE_PUPNP_SOCK_HPP
3#define INTERFACE_PUPNP_SOCK_HPP
18 virtual ~SockInterface();
23 SOCKINFO* info, SOCKET sockfd,
struct sockaddr* foreign_sockaddr) = 0;
24#ifdef UPnPsdk_HAVE_OPENSSL
29 SOCKINFO* info,
int ShutdownMethod) = 0;
31 SOCKINFO* info,
char* buffer,
size_t bufsize,
int* timeoutSecs) = 0;
33 SOCKINFO* info,
const char* buffer,
size_t bufsize,
int* timeoutSecs) = 0;
46#define INCLUDE_COMPA_SOCK_HPP
50#include <interface/pupnp-sock.hpp>
58class UPNPLIB_API Csock :
public ::SockInterface {
60 virtual ~Csock()
override =
default;
63 return ::sock_init(info, sockfd); }
65 return ::sock_init_with_ip(info, sockfd, foreign_sockaddr); }
66#ifdef UPNP_ENABLE_OPEN_SSL
70 return ::sock_destroy(info, ShutdownMethod); }
71 UPNPLIB_LOCAL
int sock_read(
SOCKINFO* info,
char* buffer,
size_t bufsize,
int* timeoutSecs)
override {
72 return ::sock_read(info, buffer, bufsize, timeoutSecs); }
73 UPNPLIB_LOCAL
int sock_write(
SOCKINFO* info,
const char* buffer,
size_t bufsize,
int* timeoutSecs)
override {
74 return ::sock_write(info, buffer, bufsize, timeoutSecs); }
76 return ::sock_make_blocking(sock); }
78 return ::sock_make_no_blocking(sock); }
79 UPNPLIB_LOCAL
int sock_close(SOCKET sock)
override {
80 return ::sock_close(sock); }
92#include <interface/pupnp-sock.hpp>
103SockInterface::~SockInterface() =
default;
Refactored pupnp program code that is compatible to the original pupnp code.
int sock_make_blocking(SOCKET sock)
Make socket blocking.
int sock_ssl_connect(SOCKINFO *info)
Associates an SSL object with the socket and begins the client-side SSL/TLS handshake.
int sock_make_no_blocking(SOCKET sock)
Make socket non-blocking.
int sock_destroy(SOCKINFO *info, int ShutdownMethod)
Shutsdown the socket using the ShutdownMethod to indicate whether sends and receives on the socket wi...
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_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...
int sock_init(SOCKINFO *info, SOCKET sockfd)
Assign the passed in socket descriptor to socket descriptor in the SOCKINFO structure.
Manage network sockets and connections.
int sock_close(SOCKET sock)
Closes the socket if it is different from -1.
Additional socket information for connections and ssl.
#define UPnPsdk_VIS
Prefix to export symbol for external use.