File tree 2 files changed +19
-3
lines changed
libraries/lwIpWrapper/src
2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ extern "C" {
8
8
9
9
/* -------------------------------------------------------------------------- */
10
10
lwipClient::lwipClient ()
11
- : _tcp_client(NULL )
11
+ : _tcp_client(NULL ), _provided_tcp_client( false )
12
12
{
13
13
}
14
14
/* -------------------------------------------------------------------------- */
@@ -17,15 +17,28 @@ lwipClient::lwipClient()
17
17
sketches but sock is ignored. */
18
18
/* -------------------------------------------------------------------------- */
19
19
lwipClient::lwipClient (uint8_t sock)
20
- : _tcp_client(NULL )
20
+ : _tcp_client(NULL ), _provided_tcp_client(false )
21
+
21
22
{
22
23
}
23
24
/* -------------------------------------------------------------------------- */
24
25
25
26
/* -------------------------------------------------------------------------- */
26
27
lwipClient::lwipClient (struct tcp_struct * tcpClient)
28
+ : _tcp_client(tcpClient), _provided_tcp_client(true )
29
+
27
30
{
28
- _tcp_client = tcpClient;
31
+ }
32
+ /* -------------------------------------------------------------------------- */
33
+
34
+ /* -------------------------------------------------------------------------- */
35
+ lwipClient::~lwipClient ()
36
+ {
37
+ stop ();
38
+
39
+ if (!_provided_tcp_client) {
40
+ mem_free (_tcp_client);
41
+ }
29
42
}
30
43
/* -------------------------------------------------------------------------- */
31
44
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ class lwipClient : public Client {
16
16
lwipClient ();
17
17
lwipClient (uint8_t sock);
18
18
lwipClient (struct tcp_struct * tcpClient);
19
+ virtual ~lwipClient ();
19
20
20
21
uint8_t status ();
21
22
virtual int connect (IPAddress ip, uint16_t port);
@@ -68,6 +69,8 @@ class lwipClient : public Client {
68
69
private:
69
70
struct tcp_struct * _tcp_client;
70
71
uint16_t _timeout = 10000 ;
72
+
73
+ const bool _provided_tcp_client;
71
74
};
72
75
73
76
#endif
You can’t perform that action at this time.
0 commit comments