Export UDP file descriptor (for android)

pull/1557/head
Jason Rhinelander 3 years ago
parent d995766436
commit f8486604c4

@ -66,6 +66,16 @@ namespace llarp::uv
bool
send(const SockAddr& dest, const llarp_buffer_t& buf) override;
std::optional<int>
file_descriptor() override
{
#ifndef _WIN32
if (int fd = handle->fd(); fd >= 0)
return fd;
#endif
return std::nullopt;
}
void
close() override;

@ -25,6 +25,14 @@ namespace llarp
virtual void
close() = 0;
// Returns the file descriptor of the socket, if available. This generally exists only after
// listen() has been called, and never exists on Windows.
virtual std::optional<int>
file_descriptor()
{
return std::nullopt;
}
// Base class destructor
virtual ~UDPHandle() = default;

@ -489,4 +489,10 @@ namespace llarp
return true;
}
std::optional<int>
ILinkLayer::GetUDPFD() const
{
return m_udp->file_descriptor();
}
} // namespace llarp

@ -222,6 +222,10 @@ namespace llarp
return m_Pending.size();
}
// Returns the file description of the UDP server, if available.
std::optional<int>
GetUDPFD() const;
private:
const SecretKey& m_RouterEncSecret;

@ -1326,7 +1326,7 @@ namespace llarp
continue;
#if defined(ANDROID)
m_OutboundUDPSocket = link->GetUDPSocket();
m_OutboundUDPSocket = link->GetUDPFD().value_or(-1);
#endif
_linkManager.AddLink(std::move(link), false);
return true;

Loading…
Cancel
Save