Error in sample code: ch 12.2 of book

The sample code in chapter 12.2 (The world simplest web browser) of book do not give the output they say.
I get the output:
= RESTART : C:/Users/…(path of computer’s working directory)…/…(file’s name)

Please, can you give me some guidance about this. I’ll appreciated very much.

can you link whatever source you are talking about?

I don’t know what that is, please provide the link to that


This is an example in chapter 12 of the book of Dr. Severance. Chapter 12 is about Networked Programs.

This code might be old/out of date.

Try this:
https://www.py4e.com/html3/12-network

import socket

mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
mysock.connect(('data.pr4e.org', 80))
cmd = 'GET http://data.pr4e.org/romeo.txt HTTP/1.0\r\n\r\n'.encode()
mysock.send(cmd)

while True:
    data = mysock.recv(512)
    if len(data) < 1:
        break
    print(data.decode(),end='')

mysock.close()

# Code: https://www.py4e.com/code3/socket1.py

You should get this response:

HTTP/1.1 200 OK
Date: Sat, 21 Jun 2025 12:28:40 GMT
Server: Apache/2.4.52 (Ubuntu)
Last-Modified: Sat, 13 May 2017 11:22:22 GMT
ETag: "a7-54f6609245537"
Accept-Ranges: bytes
Content-Length: 167
Cache-Control: max-age=0, no-cache, no-store, must-revalidate
Pragma: no-cache
Expires: Wed, 11 Jan 1984 05:00:00 GMT
Connection: close
Content-Type: text/plain

But soft what light through yonder window breaks
It is the east and Juliet is the sun
Arise fair sun and kill the envious moon
Who is already sick and pale with grief

The difference is here:

cmd = 'GET http://data.pr4e.org/romeo.txt HTTP/1.0\r\n\r\n'.encode()
cmd = 'GET http://data.pr4e.org/romeo.txt HTTP/1.0\\r\\n\\r\\n'.encode()