Endianness and web server

Viewed 100

I'm learning socket programming and I can't understand where the endianness principle is applied. I'm making a simple web server that communicates via HTTP/1.1. I found that generally no need to worry about endian issues in HTTP/1.1. But in HTTP/2 I must worry since it uses binary elements.

In case of HTTP2, should I check the type of client I'm communicating with? In order to send the data with the good endian type?

Let me know if the question is not clear.

Many thanks.

1 Answers

A server does not need to know what endian is used on clients. Network protocols that use binary data always specify what endian is transferred over network. For example HTTP/2 RFC-7540 says

All numeric values are in network byte order.

The TCP/IP standard network byte order is big-endian. So all numbers should be big-endian and server must convert them to big-endian. A client must assume everything received is big-endian and convert it to native representation.

Related