arduino-emulator
Loading...
Searching...
No Matches
ArduinoCore-Linux
cores
arduino
SocketImpl.h
1
/*
2
SocketImpl.h
3
Copyright (c) 2025 Phil Schatzmann. All right reserved.
4
5
This library is free software; you can redistribute it and/or
6
modify it under the terms of the GNU Lesser General Public
7
License as published by the Free Software Foundation; either
8
version 2.1 of the License, or (at your option) any later version.
9
10
This library is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
Lesser General Public License for more details.
14
15
You should have received a copy of the GNU Lesser General Public
16
License along with this library; if not, write to the Free Software
17
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
*/
19
20
#pragma once
21
#include <netinet/in.h>
22
#include <string.h>
23
24
namespace
arduino
{
25
26
class
SocketImpl
{
27
public
:
28
SocketImpl
() =
default
;
29
SocketImpl
(
int
socket
) {
30
sock =
socket
;
31
is_connected =
true
;
32
memset
(&serv_addr, 0,
sizeof
(serv_addr));
33
};
34
SocketImpl
(
int
socket
,
struct
sockaddr_in
* address) {
35
sock =
socket
;
36
is_connected =
true
;
37
serv_addr = *address;
38
};
39
virtual
~SocketImpl
() {
40
if
(sock != -1) {
41
close();
42
}
43
}
44
// checks if we are connected
45
virtual
uint8_t
connected();
46
// opens a conection
47
virtual
int
connect(
const
char
* address,
uint16_t
port);
48
// sends some data
49
virtual
size_t
write(
const
uint8_t
* str,
size_t
len);
50
// provides the available bytes
51
virtual
size_t
available();
52
// direct read
53
virtual
size_t
read(
uint8_t
* buffer,
size_t
len);
54
// peeks one character
55
virtual
int
peek();
56
// coloses the connection
57
virtual
void
close();
58
59
// determines the IP Adress
60
const
char
* getIPAddress();
61
// determines the IP Adress
62
const
char
* getIPAddress(
const
char
*
validEntries
[]);
63
64
virtual
void
setCACert(
const
char
*
cert
) {}
65
virtual
void
setInsecure() {}
66
int
fd() {
return
sock; }
67
68
protected
:
69
bool
is_connected =
false
;
70
int
sock = -1, valread;
71
struct
sockaddr_in
serv_addr;
72
};
73
74
}
// namespace arduino
arduino::DMABuffer
Definition
DMAPool.h:103
arduino::SocketImpl
Definition
SocketImpl.h:26
arduino
We provide the WiFi class to simulate the Arduino WIFI. In in Linux we can expect that networking is ...
Definition
CanMsg.cpp:31
Generated by
1.9.8