Translation

English
English French Actions
Sending a message to a remote peer using its IPv6 address Envoi d'un message à un homologue distant en utilisant son adresse IPv6
Now that we created an IPv6 socket, we can use it to reach another program if we know its IPv6 address. IPv6 addresses have a human-readable format that can be represented as a string of characters. The details of IPv6 addresses are out of scope of this section but here are some examples : Maintenant que nous avons créé un socket IPv6, nous pouvons l'utiliser pour atteindre un autre programme si nous connaissons son adresse IPv6. Les adresses IPv6 ont un format lisible par l'homme qui peut être représenté par une chaîne de caractères. Les détails des adresses IPv6 sont hors de portée de cette section mais voici quelques exemples :
The ``::1`` IPv6 address identifies the computer on which the current program is running. L'adresse IPv6 ``::1`` identifie l'ordinateur sur lequel le programme tourne.
The ``2001:6a8:308f:9:0:82ff:fe68:e520`` IPv6 address identifies the computer serving the ``https://beta.computer-networking.info`` website. L'adresse IPv6 ``2001:6a8:308f:9:0:82ff:fe68:e520`` identifie l'ordinateur qui dessert le site ``https://beta.computer-networking.info``.
An IPv6 address often identifies a computer and not a program running on the computer. In order to identify a specific program running on a specific computer, we use a *port number* in addition to the IPv6 address. A program using an IPv6 socket is this identified using : Une adresse IPv6 identifie souvent un ordinateur et non pas un programme exécuté sur cet ordinateur. Afin d'identifier un programme spécifique fonctionnant sur un ordinateur spécifique, nous utilisons un *numéro de port* en plus de l'adresse IPv6. Un programme utilisant un socket IPv6 est ainsi identifié par :
The IPv6 address of the computer L'adresse IPv6 de l'ordinateur
The port number identifying the program running on the computer Le port du programme qui tourne sur l'ordinateur
A program can use the ``struct sockaddr_in6`` to represent IPv6 socket addresses. The following program creates a ``struct sockaddr_in6`` that identifies the program that reserved the port number ``55555`` on the computer identified by the ``::1`` IPv6 address. Un programme peut utiliser la structure sockaddr_in6 pour représenter les adresses de socket IPv6. Le programme suivant crée une ``struct sockaddr_in6`` qui identifie le programme ayant réservé le numéro de port ``55555`` sur l'ordinateur identifié par l'adresse IPv6 ``::1``.
Now, we have built everything we need to send a message to the remote program. The ``create_socket_and_send_message`` function below assembles all the building blocks we created until now in order to send the message ``"hello"`` to the program running on port ``55555`` on the computer identified by the ``::1`` IPv6 address. Maintenant, nous avons construit tout ce dont nous avons besoin pour envoyer un message au programme distant. La fonction ``create_socket_and_send_message`` ci-dessous assemble toutes les briques que nous avons créées jusqu'à présent afin d'envoyer le message ``hello"`` au programme tournant sur le port ``55555`` sur l'ordinateur identifié par l'adresse IPv6 ``::1``.
Note that we can reuse our ``send_hello_to_peer`` function without any modification as we wrote it to handle any kind of sockets, including sockets using the IPv6 network protocol. Notez que nous pouvons réutiliser notre fonction ``send_hello_to_peer`` sans aucune modification puisque nous l'avons écrite pour gérer tout type de sockets, y compris les sockets utilisant le protocole réseau IPv6.
Endianness: exchanging integers between different computers Endianness : échange d'entiers entre différents ordinateurs
Besides character strings, some applications also need to exchange 16 bits and 32 bits fields such as integers. A naive solution would have been to send the 16- or 32-bits field as it is encoded in the host's memory. Unfortunately, there are different methods to store 16- or 32-bits fields in memory. Some CPUs store the most significant byte of a 16-bits field in the first address of the field while others store the least significant byte at this location. When networked applications running on different CPUs exchange 16 bits fields, there are two possibilities to transfer them over the transport service : Outre les chaînes de caractères, certaines applications doivent également échanger des champs de 16 et 32 bits tels que des entiers. Une solution naïve aurait été d'envoyer le champ de 16 ou 32 bits tel qu'il est codé dans la mémoire de l'hôte. Malheureusement, il existe différentes méthodes pour stocker les champs de 16 ou 32 bits en mémoire. Certains processeurs stockent l'octet le plus significatif d'un champ de 16 bits dans la première adresse du champ, tandis que d'autres stockent l'octet le moins significatif à cet endroit. Lorsque des applications en réseau fonctionnant sur des unités centrales différentes échangent des champs de 16 bits, il existe deux possibilités pour les transférer via le service de transport :
send the most significant byte followed by the least significant byte envoyer l'octet le plus significatif suivi de l'octet le moins significatif
send the least significant byte followed by the most significant byte envoyer l'octet le moins significatif suivi de l'octet le plus significatif
Besides 16 and 32 bit words, some applications need to exchange data structures containing bit fields of various lengths. For example, a message may be composed of a 16 bits field followed by eight, one bit flags, a 24 bits field and two 8 bits bytes. Internet protocol specifications will define such a message by using a representation such as the one below. In this representation, each line corresponds to 32 bits and the vertical lines are used to delineate fields. The numbers above the lines indicate the bit positions in the 32-bits word, with the high order bit at position `0`. Outre les mots de 16 et 32 bits, certaines applications doivent échanger des structures de données contenant des champs de bits de différentes longueurs. Par exemple, un message peut être composé d'un champ de 16 bits suivi de huit drapeaux d'un bit, d'un champ de 24 bits et de deux octets de 8 bits. Les spécifications du protocole Internet définiront un tel message en utilisant une représentation telle que celle qui suit. Dans cette représentation, chaque ligne correspond à 32 bits et les lignes verticales sont utilisées pour délimiter les champs. Les chiffres au-dessus des lignes indiquent la position des bits dans le mot de 32 bits, le bit de poids fort étant en position "0".
Message format Format du message
The message mentioned above will be transmitted starting from the upper 32-bits word in network byte order. The first field is encoded in 16 bits. It is followed by eight one bit flags (`A-H`), a 24 bits field whose high order byte is shown in the first line and the two low order bytes appear in the second line followed by two one byte fields. This ASCII representation is frequently used when defining binary protocols. We will use it for all the binary protocols that are discussed in this book. Le message mentionné ci-dessus sera transmis en commençant par le mot supérieur de 32 bits dans l'ordre des octets du réseau. Le premier champ est codé sur 16 bits. Il est suivi de huit drapeaux d'un bit (`A-H`), d'un champ de 24 bits dont l'octet de poids fort figure sur la première ligne et les deux octets de poids faible apparaissent sur la deuxième ligne, suivis de deux champs d'un octet. Cette représentation ASCII est fréquemment utilisée lors de la définition de protocoles binaires. Nous l'utiliserons pour tous les protocoles binaires abordés dans ce livre.
Exercises Exercices
Here are some exercises that will help you to learn how to use sockets. Voici quelques exercices qui vous permettront d'apprendre à utiliser les sockets.
Footnotes Notes de pied de page
For example, the ``htonl(3)`` (resp. ``ntohl(3)``) function the standard C library converts a 32-bits unsigned integer from the byte order used by the CPU to the network byte order (resp. from the network byte order to the CPU byte order). Similar functions exist in other programming languages. Par exemple, la fonction ``htonl(3)`` (resp. ``ntohl(3)``) de la bibliothèque C standard convertit un entier non signé de 32 bits de l'ordre des octets utilisé par le CPU à l'ordre des octets du réseau (resp. de l'ordre des octets du réseau à l'ordre des octets du CPU). Des fonctions similaires existent dans d'autres langages de programmation.
Component Translation Difference to current string
This translation Propagated Translated cnp3-ebook/exercises/sockets
The following string has the same context and source.
Propagated Translated cnp3-ebook/principles/transport

Loading…

User avatar pdan1

New translation

cnp3-ebook / exercises/socketsFrench

2 years ago
Browse all component changes

Glossary

English French
No related strings found in the glossary.

String information

Source string location
../../exercises/sockets.rst:335
String age
4 years ago
Source string age
4 years ago
Translation file
locale/fr/LC_MESSAGES/exercises/sockets.po, string 45