raw icon indicating copy to clipboard operation
raw copied to clipboard

htons should depend on host endianness

Open bhesmans opened this issue 4 years ago • 0 comments

func htons should take host endianness into account:

func htons(i uint16) uint16 {
	return (i<<8)&0xff00 | i>>8
}

Depending on host endianness this should be a no-op or not.

The issue was spotted when trying to use this lib on a device with a different endianness...

bhesmans avatar Dec 16 '21 14:12 bhesmans