Python Forum
TCp code explained - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Networking (https://python-forum.io/forum-12.html)
+--- Thread: TCp code explained (/thread-3370.html)



TCp code explained - zarnav - May-18-2017

Hey guys,

I am new to this field and I would like to get some assistance in explaining this code's output.
Currently when I run it doesn't produce any output. I am using WingIDE.

import socket

target_host = "www.google.com"
target_port = 80

#create a socket object

client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

#connect the client

client.connect((target_host,target_port))

#send some data

client.send("GET / HTTP/1.1\r\nHOST: google.com\r\n\r\n")

#receive some data

response = client.recv(4096)



RE: TCp code explained - Larz60+ - May-18-2017

add the following after line 20
print(response)



RE: TCp code explained - zarnav - May-18-2017

Thanks! forgot to add that LoL! Dance Dance