c - Socket programming - why do we not convert sin_family to network order? -


below example of valid socket creation (in c):

  // construct local address structure   struct sockaddr_in servaddr;                  // local address   memset(&servaddr, 0, sizeof(servaddr));       // 0 out structure   servaddr.sin_family = af_inet;                // ipv4 address family   servaddr.sin_addr.s_addr = htonl(inaddr_any); // incoming interface   servaddr.sin_port = htons(servport);          // local port 

we need convert address , port network order not address family. why that?

sin_family isn't sent on network, there's no need use network byte order. it's local flag operating system only. indicates polymorphic type of struct sockaddr * pointer, because ipv4 isn't format. af_unix address doesn't ip address , port fields, instance.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -