Python: import socket ; socket.socket() ; socket.connect() ; socket.send()

加入好友
加入社群
Python: import socket ; socket.socket() ; socket.connect() ; socket.send() - 儲蓄保險王

import socket
import time
#import numpy as np
HOST = ‘192.168.2.11’
ctrl_socket = 0
data_socket = 0
ctrl_port = 8000
data_port = 8001

ctrl_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
data_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# family: 串接的類型可分為 IPv4本機、IPv4網路、IPv6網路,type: 串接可分為TCP/UDP
# ctrl_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# data_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

ctrl_socket.connect((HOST, ctrl_port))
# 用於客戶端指定要串接的IP位址跟Port號
time.sleep(0.2)
data_socket.connect((HOST, data_port))
print(data_socket)
print(ctrl_socket)
data_socket.send(b’Config’)

Python: import socket ; socket.socket() ; socket.connect() ; socket.send() - 儲蓄保險王

 

Jupyter:

Python: import socket ; socket.socket() ; socket.connect() ; socket.send() - 儲蓄保險王

 

推薦hahow線上學習python: https://igrape.net/30afN

加入好友
加入社群
Python: import socket ; socket.socket() ; socket.connect() ; socket.send() - 儲蓄保險王

儲蓄保險王

儲蓄險是板主最喜愛的儲蓄工具,最喜愛的投資理財工具則是ETF,最喜愛的省錢工具則是信用卡

You may also like...

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *