Click here to Skip to main content
15,881,413 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I wrote a Python program in python 3.4.3 But it is not showing any output. how can i get outpu please help

What I have tried:

Python
import socket
mysock=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
mysock.connect(("www.py4inf.com",80))
mysock.send("GET http://www.py4inf.com/code/romeo.txt HTTP/1.0\n\n".encode('ascii'))
while True:
	data=mysock.recv(512)
	if(len(data)<1):
            break
            print (data.decode('ascii'))
mysock.close()
Posted
Updated 7-Apr-16 21:21pm

1 solution

Python
if(len(data)<1):
        break
        print (data.decode('ascii'))

So if the length of the data is less than 1 you break out of the while loop. If it is equal or greater than 1 you continue the loop. But in either case you never reach the print statement.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900