Open aberaud opened 1 year ago
https://think-async.com/Asio/asio-1.28.0/doc/asio/reference/ip__basic_endpoint/data.html
Thanks a lot ! This solves half of the issue, as it converts to sockaddr.
Any update ? data()
provides access to the native type but there is no clean/official way to convert from a native address type to an asio endpoint.
I've seen so many different / custom code to achieve this, it's a major waste of time and cause of bugs.
I've been converting UNIX code to ASIO C++, and one of the most significant friction point is that there seem to be no simple way to build
asio::ip::udp::endpoint
orasio::ip::tcp::endpoint
from the standardstruct sockaddr*.
This is a pain-point when interfacing ASIO code with C libraries or other parts of the code that use struct sockaddr*.
I've been generating the following conversion routine with ChatGPT (see bellow), but it seems bug-prone and inefficient. It seems like the standard struct sockaddr is supported on every platform supported by ASIO ? So it might be possible to have conversion routines from struct sockaddr part of ASIO ? Or is it something that already exists and that I've been missing ? Many thanks.