Skip to content

Commit 2ea8c7e

Browse files
committed
Week 3- Networks and Sockets
1 parent ff5abeb commit 2ea8c7e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import socket
2+
3+
mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
4+
mysock.connect(('data.pr4e.org', 80))
5+
6+
cmd = 'GET http://data.pr4e.org/romeo.txt HTTP/1.0\r\n\r\n'.encode()
7+
mysock.send(cmd)
8+
9+
while True:
10+
data = mysock.recv(512)
11+
if(len(data) < 1):
12+
break
13+
print(data.decode())
14+
mysock.close()

0 commit comments

Comments
 (0)