mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 05:24:53 +01:00
Socket: Add recvfrom method to receive UDP with source address. (#6103)
This commit is contained in:
parent
21337ffc67
commit
3854203037
2 changed files with 10 additions and 0 deletions
|
@ -86,6 +86,13 @@ class BSDSocketImpl : public Socket {
|
|||
}
|
||||
int listen(int backlog) override { return ::listen(fd_, backlog); }
|
||||
ssize_t read(void *buf, size_t len) override { return ::read(fd_, buf, len); }
|
||||
ssize_t recvfrom(void *buf, size_t len, sockaddr *addr, socklen_t *addr_len) override {
|
||||
#if defined(USE_ESP32)
|
||||
return ::recvfrom(this->fd_, buf, len, 0, addr, addr_len);
|
||||
#else
|
||||
return ::lwip_recvfrom(this->fd_, buf, len, 0, addr, addr_len);
|
||||
#endif
|
||||
}
|
||||
ssize_t readv(const struct iovec *iov, int iovcnt) override {
|
||||
#if defined(USE_ESP32)
|
||||
return ::lwip_readv(fd_, iov, iovcnt);
|
||||
|
|
|
@ -31,6 +31,9 @@ class Socket {
|
|||
virtual int setsockopt(int level, int optname, const void *optval, socklen_t optlen) = 0;
|
||||
virtual int listen(int backlog) = 0;
|
||||
virtual ssize_t read(void *buf, size_t len) = 0;
|
||||
#ifdef USE_SOCKET_IMPL_BSD_SOCKETS
|
||||
virtual ssize_t recvfrom(void *buf, size_t len, sockaddr *addr, socklen_t *addr_len) = 0;
|
||||
#endif
|
||||
virtual ssize_t readv(const struct iovec *iov, int iovcnt) = 0;
|
||||
virtual ssize_t write(const void *buf, size_t len) = 0;
|
||||
virtual ssize_t writev(const struct iovec *iov, int iovcnt) = 0;
|
||||
|
|
Loading…
Reference in a new issue