htonl
Diferenças
Aqui você vê as diferenças entre duas revisões dessa página.
— | htonl [2023/09/12 16:14] (atual) – criada - edição externa 127.0.0.1 | ||
---|---|---|---|
Linha 1: | Linha 1: | ||
+ | ====== Funções htonl, htons, ntohl, ntohs ====== | ||
+ | Sintaxe: | ||
+ | |||
+ | '' | ||
+ | |||
+ | '' | ||
+ | |||
+ | '' | ||
+ | |||
+ | '' | ||
+ | |||
+ | ---- | ||
+ | |||
+ | As funções convertem e retornam um o endereço passado como parâmetro para um ordenamento de byte significativo. Sendo que as funções **htons** e **htonl** retornam o valor na ordem de bytes da rede e as funções **ntohs** e **ntohl** retornam o valor na ordem de bytes de um host. | ||
+ | |||
+ | * htons - //Host to Network Short// | ||
+ | * htonl - //Host to Network Long// | ||
+ | * ntohs - //Network to Host Short// | ||
+ | * ntohl - //Network to Host Long// | ||
+ | |||
+ | Veja o exemplo: | ||
+ | <code c> | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | |||
+ | int main(void) | ||
+ | { | ||
+ | int iSock; | ||
+ | | ||
+ | |||
+ | iSock = socket(AF_INET, | ||
+ | if( iSock == -1) | ||
+ | { | ||
+ | perror(" | ||
+ | exit(1); | ||
+ | } | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | --- // |