GameDevTecnico / cubos

A still very barebones game engine focused on voxels and data-oriented programming
https://cubosengine.org
MIT License
83 stars 36 forks source link

Add network Address class #1211

Closed RiscadoA closed 3 months ago

RiscadoA commented 4 months ago

Header: core/net/address.hpp Source files: core/net/address.cpp

Class name: cubos::core::net::Address

It should provide:

roby2014 commented 4 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) ?

RiscadoA commented 4 months ago

Just a 32 bit value, I think, to avoid exposing the headers

roby2014 commented 4 months ago

So whats the point of having posix and windows address.hpp ? The implementation should be similar, or actually, the same

RiscadoA commented 4 months ago

We won't have two headers, only two different source files. Only one of them is used in each platform

roby2014 commented 4 months ago

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

RiscadoA commented 4 months ago

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.

roby2014 commented 4 months ago

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?

RiscadoA commented 3 months ago

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?

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!