Last active
August 22, 2016 04:07
-
-
Save mhtsai1010/7fcdcb644b102f07c909 to your computer and use it in GitHub Desktop.
Python: tcp client sockets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import socket | |
target_host = "127.0.0.1" | |
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("input some data here") | |
# receive some data | |
response = client.recv(4096) | |
# print response | |
print response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment