libUTL++
SSLsocket.h
1 #pragma once
2 
4 
5 #include <libutl/InetHostAddress.h>
6 #include <libutl/Stream.h>
7 
9 
10 extern "C" {
11 struct bio_st;
12 struct ssl_st;
13 typedef bio_st BIO;
14 typedef ssl_st SSL;
15 }
16 
18 
19 UTL_NS_BEGIN;
20 
22 
30 
32 class SSLsocket : public Stream
33 {
35 
36 public:
42  SSLsocket(const InetHostAddress& hostAddr, uint16_t port);
43 
49  void open(const InetHostAddress& hostAddr, uint16_t port);
50 
51  virtual void close();
52 
57  bool certificateOK() const;
58 
59  virtual size_t read(byte_t* array, size_t maxBytes, size_t minBytes = size_t_max);
60 
61  virtual void write(const byte_t* array, size_t num);
62 
63 private:
64  void
65  init()
66  {
67  _bio = nullptr;
68  }
69  void
70  deInit()
71  {
72  close();
73  }
74 
75 private:
76  BIO* _bio;
77 };
78 
80 
81 UTL_NS_END;
void deInit()
De-initialize UTL++.
#define UTL_CLASS_DECL(DC, BC)
Declaration of standard UTL++ functionality for a non-template class.
Definition: macros.h:688
unsigned char byte_t
Unsigned character.
Definition: types.h:31
const size_t size_t_max
Maximum size_t value.
Secure socket.
Definition: SSLsocket.h:32
Stream I/O abstraction.
Definition: Stream.h:68
unsigned short uint16_t
Unsigned 16-bit integer.
Definition: types.h:101
void init()
Initialize UTL++.
Internet host address.