We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8d961d4 commit 66867a5Copy full SHA for 66867a5
1 file changed
Web Socket.py
@@ -1,9 +1,16 @@
1
# Program to print a data & it's Metadata of online uploaded file using "socket".
2
import socket
3
-skt_c = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
4
-skt_c.connect(("data.pr4e.org", 80))
5
-link = "GET http://data.pr4e.org/intro-short.txt HTTP/1.0\r\n\r\n".encode()
6
-skt_c.send(link)
+from colorama import Fore # this module for Color the font
+
+# handling the exceptions
+try:
7
+ skt_c = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
8
+ skt_c.connect(("data.pr4e.org", 80))
9
+ link = "GET http://data.pr4e.org/intro-short.txt HTTP/1.0\r\n\r\n".encode()
10
+ skt_c.send(link)
11
+except(Exception) as e:
12
+ # this code runes on error in any connection
13
+ print(Fore.RED, e, Fore.RESET)
14
15
while True:
16
data = skt_c.recv(512)
0 commit comments