File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change 11# Program to print a data & it's Metadata of online uploaded file using "socket".
22import 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 )
3+ from colorama import Fore # this module for Color the font
4+
5+ # handling the exceptions
6+ 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 )
714
815while True :
916 data = skt_c .recv (512 )
You can’t perform that action at this time.
0 commit comments