Closed RiscadoA closed 3 months ago
What is the main purpose, will this store as state just a 32 bit value, or should it hold the socket implementation (WSADATA
for windows and int
for linux) ?
Just a 32 bit value, I think, to avoid exposing the headers
So whats the point of having posix and windows address.hpp
? The implementation should be similar, or actually, the same
We won't have two headers, only two different source files. Only one of them is used in each platform
We won't have two headers, only two different source files. Only one of them is used in each platform
Yes but why? What would differ in storing a simple 32bit value in terms of the implementation proposed
I meant having a single address.hpp
, which stores a single 32 bit value. Then, there are two .cpp files, one used in windows, another one used in posix. The implementation of the functions is what differs on the two .cpp files, but the interface is the same, and thats why there is only a single .hpp file. For example, the from
function implementation differs on Posix and Windows.
See my PR implementation above. It will make a bit more sense why I am asking I think. The major implementation is similar, only some functions differ (such as from
). But if the major is similar, can't we just use ifdef
for those specific functions?
See my PR implementation above. It will make a bit more sense why I am asking I think. The major implementation is similar, only some functions differ (such as
from
). But if the major is similar, can't we just useifdef
for those specific functions?
Ahhh, I understand. Indeed, in this class the functions are mostly same, it's better to use #ifdef
yeah. For consistency we should do the same for the socket and listener classes too then. Ty!
Header:
core/net/address.hpp
Source files:core/net/address.cpp
Class name:
cubos::core::net::Address
It should provide:
static Opt<Address> from(const std::string& address)
, can receive any IP or URL. Returns none on error.static const Address Any
- 0.0.0.0.static const Address LocalHost
- 127.0.0.1.StringConversionTrait
.