.. index:: pair: class; EE::Network::SSL::SSLSocket .. _doxid-class_e_e_1_1_network_1_1_s_s_l_1_1_s_s_l_socket: class EE::Network::SSL::SSLSocket ================================= .. toctree:: :hidden: Overview ~~~~~~~~ TLS over TCP socket implementation. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include class SSLSocket: public :ref:`EE::Network::TcpSocket` { public: // fields static std::string :ref:`CertificatesPath`; // construction :target:`SSLSocket`(std::string hostname, bool validateCertificate, bool validateHostname, SSLSocket* restoreSession = NULL); virtual :target:`~SSLSocket`(); // methods static bool :target:`init`(); static bool :target:`end`(); static bool :ref:`isSupported`(); static SSLSocket* :target:`New`(std::string hostname, bool validateCertificate, bool validateHostname, SSLSocket* restoreSession = NULL); virtual :ref:`Status` :ref:`connect`(const :ref:`IpAddress`& remoteAddress, unsigned short remotePort, :ref:`Time` timeout = Time::Zero); virtual void :ref:`disconnect`(); virtual :ref:`Status` :ref:`send`(const void* data, std::size_t size); virtual :ref:`Status` :ref:`receive`(void* data, std::size_t size, std::size_t& received); virtual :ref:`Status` :ref:`send`(:ref:`Packet`& packet); virtual :ref:`Status` :ref:`receive`(:ref:`Packet`& packet); :ref:`Status` :target:`sslConnect`(const :ref:`IpAddress`& remoteAddress, unsigned short remotePort, :ref:`Time` timeout = Time::Zero); void :target:`sslDisconnect`(); :ref:`Status` :target:`tcpConnect`(const :ref:`IpAddress`& remoteAddress, unsigned short remotePort, :ref:`Time` timeout = Time::Zero); void :target:`tcpDisconnect`(); :ref:`Status` :target:`tcpReceive`(void* data, std::size_t size, std::size_t& received); :ref:`Status` :target:`tcpSend`(const void* data, std::size_t size, std::size_t& sent); }; Inherited Members ----------------- .. ref-code-block:: cpp :class: doxyrest-overview-inherited-code-block public: // typedefs typedef std::function :ref:`ReadFn`; // enums enum { :ref:`AnyPort` = 0, }; enum :ref:`Status`; // structs struct :ref:`PendingPacket`; // methods void :ref:`setBlocking`(bool blocking); bool :ref:`isBlocking`() const; static :ref:`TcpSocket`* :ref:`New`(); unsigned short :ref:`getLocalPort`() const; :ref:`IpAddress` :ref:`getRemoteAddress`() const; unsigned short :ref:`getRemotePort`() const; virtual :ref:`Status` :ref:`connect`(const :ref:`IpAddress`& remoteAddress, unsigned short remotePort, :ref:`Time` timeout = Time::Zero); virtual void :ref:`disconnect`(); virtual :ref:`Status` :ref:`send`(const void* data, std::size_t size); virtual :ref:`Status` :ref:`send`(const void* data, std::size_t size, std::size_t& sent); virtual :ref:`Status` :ref:`receive`(void* data, std::size_t size, std::size_t& received); virtual :ref:`Status` :ref:`send`(:ref:`Packet`& packet); virtual :ref:`Status` :ref:`receive`(:ref:`Packet`& packet); void :ref:`setSendTimeout`(:ref:`SocketHandle` sock, const :ref:`Time`& timeout); void :ref:`setReceiveTimeout`(:ref:`SocketHandle` sock, const :ref:`Time`& timeout); void :ref:`startAsyncRead`(:ref:`ReadFn` readFn = nullptr); .. _details-class_e_e_1_1_network_1_1_s_s_l_1_1_s_s_l_socket: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ TLS over TCP socket implementation. Fields ------ .. index:: pair: variable; CertificatesPath .. _doxid-class_e_e_1_1_network_1_1_s_s_l_1_1_s_s_l_socket_1aeeb08a32bfb98cf1323e564e22698659: .. ref-code-block:: cpp :class: doxyrest-title-code-block static std::string CertificatesPath This is the certificate location in the file system. If no certificate path is provided it will try to use the default CA bundle provided in most OSes. If no CA bundle is found on the current OS it will fallback to "assets/ca-bundle.pem". The path can be inside of any open :ref:`EE::System::Pack `. This should be set before using any :ref:`SSLSocket ` connection. Methods ------- .. index:: pair: function; isSupported .. _doxid-class_e_e_1_1_network_1_1_s_s_l_1_1_s_s_l_socket_1a34db29125794c9342fddfe3ed7088153: .. ref-code-block:: cpp :class: doxyrest-title-code-block static bool isSupported() .. rubric:: Returns: True when the library was compiled with :ref:`SSL ` support. .. index:: pair: function; connect .. _doxid-class_e_e_1_1_network_1_1_s_s_l_1_1_s_s_l_socket_1acc2025072db4436175d1568f4189b1b1: .. ref-code-block:: cpp :class: doxyrest-title-code-block virtual :ref:`Status` connect(const :ref:`IpAddress`& remoteAddress, unsigned short remotePort, :ref:`Time` timeout = Time::Zero) Connect the socket to a remote peer In blocking mode, this function may take a while, especially if the remote peer is not reachable. The last parameter allows you to stop trying to connect after a given timeout. If the socket was previously connected, it is first disconnected. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - remoteAddress - Address of the remote peer * - remotePort - Port of the remote peer * - timeout - Optional maximum time to wait .. rubric:: Returns: Status code .. rubric:: See also: Disconnect .. index:: pair: function; disconnect .. _doxid-class_e_e_1_1_network_1_1_s_s_l_1_1_s_s_l_socket_1aa5edb5acd01e3973bb48b476943e9d33: .. ref-code-block:: cpp :class: doxyrest-title-code-block virtual void disconnect() Disconnect the socket from its remote peer This function gracefully closes the connection. If the socket is not connected, this function has no effect. .. rubric:: See also: Connect .. index:: pair: function; send .. _doxid-class_e_e_1_1_network_1_1_s_s_l_1_1_s_s_l_socket_1afa6ba7b82cf0522d6635d0e23c592d3d: .. ref-code-block:: cpp :class: doxyrest-title-code-block virtual :ref:`Status` send(const void* data, std::size_t size) Send raw data to the remote peer To be able to handle partial sends over non-blocking sockets, use the :ref:`send(const void\*, std::size_t, std::size_t&) ` overload instead. This function will fail if the socket is not connected. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - data - Pointer to the sequence of bytes to send * - size - Number of bytes to send .. rubric:: Returns: Status code .. rubric:: See also: Receive .. index:: pair: function; receive .. _doxid-class_e_e_1_1_network_1_1_s_s_l_1_1_s_s_l_socket_1a30c8d76ecdc52be94564f48ce1610e32: .. ref-code-block:: cpp :class: doxyrest-title-code-block virtual :ref:`Status` receive(void* data, std::size_t size, std::size_t& received) Receive raw data from the remote peer In blocking mode, this function will wait until some bytes are actually received. This function will fail if the socket is not connected. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - data - Pointer to the array to fill with the received bytes * - size - Maximum number of bytes that can be received * - received - This variable is filled with the actual number of bytes received .. rubric:: Returns: Status code .. rubric:: See also: Send .. index:: pair: function; send .. _doxid-class_e_e_1_1_network_1_1_s_s_l_1_1_s_s_l_socket_1adfad888a14a7bc00deadd1247f7bf5cf: .. ref-code-block:: cpp :class: doxyrest-title-code-block virtual :ref:`Status` send(:ref:`Packet`& packet) Send a formatted packet of data to the remote peer. In non-blocking mode, if this function returns sf::Socket::Partial, you *must* retry sending the same unmodified packet before sending anything else in order to guarantee the packet arrives at the remote peer uncorrupted. This function will fail if the socket is not connected. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - packet - :ref:`Packet ` to send .. rubric:: Returns: Status code .. rubric:: See also: Receive .. index:: pair: function; receive .. _doxid-class_e_e_1_1_network_1_1_s_s_l_1_1_s_s_l_socket_1a7cbc90308bb2f02e59dc4fa43fff9f0b: .. ref-code-block:: cpp :class: doxyrest-title-code-block virtual :ref:`Status` receive(:ref:`Packet`& packet) Receive a formatted packet of data from the remote peer In blocking mode, this function will wait until the whole packet has been received. This function will fail if the socket is not connected. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - packet - :ref:`Packet ` to fill with the received data .. rubric:: Returns: Status code .. rubric:: See also: Send