Python 簡易TCP客戶端

2021-07-16 14:56:17 字數 782 閱讀 7249

#!usr/bin/python

#-*- coding: utf-8 -*-

#socket 程式設計

#**學習自《black hat python:python programming for hackers and pentesters》

#簡單的tcp客戶端

target_port = 80#http協議預設埠

#build a socket object.

client = socket.socket(socket.af_inet,socket.sock_stream)

'''af_inet ==> ipv4

af_inet6 ==> ipv6

sock_stream ==> tcp client

'''#連線客戶端

client.connect((target_host,target_port))#引數是乙個tuple,包含位址和埠號

#傳送資料

#接受資料

response = client.recv(4096)#4k位元組

print response

效果圖:

python小練習 TCP客戶端

這是python黑帽子上的起始練習,我對其中的用到的函式做了注釋,以便日後便於理解。另外,我注釋還有一部分udp客戶端的語句,tcp和udp對比便於記憶。coding utf 8 建立客戶端,類似於瀏覽器傳送請求 建立乙個socket物件 client socket.socket socket.af...

TCP通訊(客戶端)

修改自網路 include include include pragma comment lib,ws2 32.lib int client void unsigned short port int main int argc,char argv int client void if isockcl...

ORACLE 簡易客戶端配置

2 將該路徑增加到系統環境變數 path 中,然後將下面的登錄檔檔案匯入到登錄檔中 windows registry editor version 5.00 hkey local machine software wow6432node oracle nls lang simplified chin...