Diferències
Ací es mostren les diferències entre la revisió seleccionada i la versió actual de la pàgina.
| Següent revisió | Revisió prèvia | ||
| info:cursos:pue:python-pcpp1:m4:1.2 [08/01/2024 20:17] – creat mate | info:cursos:pue:python-pcpp1:m4:1.2 [05/03/2024 09:09] (actual) – [Requesting a document from a server: continued] mate | ||
|---|---|---|---|
| Línia 40: | Línia 40: | ||
| The user input may can take two different forms: | The user input may can take two different forms: | ||
| - | * it can be **the domain name of the server** (like // | + | * it can be **the domain name of the server** (like // |
| * it can be **the IP address of the server** (like 87.98.235.184), | * it can be **the IP address of the server** (like 87.98.235.184), | ||
| It may sound cynical - it's not our problem which of these two ways our users choose. They know better. The customer is always right. | It may sound cynical - it's not our problem which of these two ways our users choose. They know better. The customer is always right. | ||
| Línia 59: | Línia 59: | ||
| As you can see, the constructor takes two arguments, both declared within the module. Let us tell you about them: | As you can see, the constructor takes two arguments, both declared within the module. Let us tell you about them: | ||
| - | * the former argument is a domain code (we may use the '' | + | * the former argument is a domain code (we may use the '' |
| * the latter argument is a socket type code (we may use the '' | * the latter argument is a socket type code (we may use the '' | ||
| Línia 129: | Línia 129: | ||
| === Requesting a document from a server | === Requesting a document from a server | ||
| Yes, it's send - look at how we combine it with our code from the previous lesson: | Yes, it's send - look at how we combine it with our code from the previous lesson: | ||
| - | < | + | < |
| sock.send(b" | sock.send(b" | ||
| bytes(server_addr, | bytes(server_addr, | ||
| Línia 179: | Línia 179: | ||
| The argument specifies the maximal acceptable length of the data to be received. If the server' | The argument specifies the maximal acceptable length of the data to be received. If the server' | ||
| - | You will need to invoke '' | + | You will need to invoke '' |
| There are lots of bad things which can spoil our game. For example, the server may not want to talk with us. | There are lots of bad things which can spoil our game. For example, the server may not want to talk with us. | ||
| Línia 273: | Línia 273: | ||
| In fact, we see two separate parts: | In fact, we see two separate parts: | ||
| - | * the first is the response header. We'll tell you a little secret - the topmost line is the most important, as is says whether the server sent back the requested document or not. Look, there is a very significant three-digit number: '' | + | * the first is the response header. We'll tell you a little secret - the topmost line is the most important, as is says whether the server sent back the requested document or not. Look, there is a very significant three-digit number: '' |
| * the document. Yes, this is the place where it starts. It may very bloated (it usually is) and we don't want to present it in full.\\It' | * the document. Yes, this is the place where it starts. It may very bloated (it usually is) and we don't want to present it in full.\\It' | ||