Service port numbers returned in network byte order, cannot be used meaningfully
- Dominant language
- Haskell
- Stars
- 7
- Forks
- 8
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I admit I didn't take too much time to dig into this, but it looks like `getServiceByName` / `getServicePortNumber` return `PortNumber instances` in _network byte order_ which seems incompatible with the rest of the Network.Socket API:
```haskell
GHCi, version 8.8.4: https://www.haskell.org/ghc/ :? for help
Prelude> :m +Network.BSD
Prelude Network.BSD> getServicePortNumber "http"
20480
```
(`20480` is the same as `htons(80)` on amd64)
This might be related to Network 2.8.0.0 changing the internal representation of `PortNumber` to hold a Word16 in _host byte order_ (https://github.com/haskell/network/pull/347). The end result is that port numbers returned by `getServicePortNumber` and/or `getServiceByName` cannot be meaningfully used for anything:
```haskell
Prelude Network.BSD> port <- getServicePortNumber "http"
Prelude Network.BSD> port
20480
Prelude Network.BSD> (80 :: PortNumber) == port
False
```
See https://github.com/ganeti/ganeti/issues/1600 for a real-world example.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.