完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
请注意,我使用的是Python语言进行编写:
import socket def send_request(host, port, path): """ Send a GET request to a server with the specified host, port, and path. Returns the response from the server. """ # Create a socket and connect to the server s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((host, port)) # Send the GET request to the server request = "GET {} HTTP/1.1rnHost: {}rnrn".format(path, host) s.send(request.encode()) # Receive the response from the server response = "" while True: data = s.recv(1024) if not data: break response += data.decode() # Close the connection to the server s.close() return response # Send a request to Server 1 response1 = send_request("server1.com", 80, "/path/to/resource") # Send a request to Server 2 response2 = send_request("server2.com", 80, "/path/to/other/resource") |
|
|
|
只有小组成员才能发言,加入小组>>
1106 浏览 1 评论
574浏览 6评论
477浏览 5评论
有没有办法在不使用混杂模式的情况下实现Wifi驱动程序接收缓冲区访问中断呢?
460浏览 5评论
461浏览 4评论
435浏览 4评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-18 12:48 , Processed in 0.793646 second(s), Total 76, Slave 60 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号