I am new to TCP/IP connection using python
I have this simple code:
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("www.google.com",80))
s.send("GET /\n")
while 1:
received = s.recv(1024)
if received:
print received
but when I run it it just runs forever and does not give me any result!!!
Could you please help me. Thanks
Follow HTTP Protocol
This is not correct. You should send http data in a proper way. Use this
In fact you are to send standard http request headers.
Note: As David says in the comment you must be able to decode chunked transfer coding. So its better you state
HTTP/1.0in the header.