zpl-c / enet

⚡️ ENet reliable UDP networking library
https://blog.zpl.pw
MIT License
703 stars 60 forks source link

enet_address_set_host_ip doesn't work with IPv4 address #12

Closed mirasrael closed 2 years ago

mirasrael commented 5 years ago

If you try to call:

enet_address_set_host_ip(address, "127.0.0.1")

then it will produce following IPv6 bytes:

{127, 0, 0, 1, 0, ...., 0}

And if pass this address to enet_host_create then it will fail to create a host. But if you call:

enet_address_set_host(address, "127.0.0.1")

or

enet_address_set_host(address, "localhost")

then it will resolve to:

{0, ...., 0, 255, 255, 127, 0, 0, 1}

and everything works fine.

nxrighthere commented 5 years ago

ENetAddress and dependent functionality needs rework to fix this. I've properly implemented it here.

inlife commented 5 years ago

@nxrighthere I'm assuming this is the exact commit that fixed the issue: https://github.com/nxrighthere/ENet-CSharp/commit/006ed258dca4af09effdeed3d1d417f3c6b04b2a

Correct?

nxrighthere commented 5 years ago

I made some additional tweaks after implementing this, but yes, this commit is when it was done initially.

OptoCloud commented 3 years ago

@nxrighthere @inlife i might have fixed it, but i am very new to network programming and might have made mistakes: https://github.com/zpl-c/enet/pull/22