You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
618 B
31 lines
618 B
# @Coding: utf-8
|
|
# @Time: 2022/4/25 3:45 下午
|
|
import time
|
|
import socket
|
|
import sys
|
|
import argparse
|
|
import os
|
|
|
|
host = '192.168.43.47'#改成你的虚拟机ip地址
|
|
port = 8080#建议
|
|
|
|
username = sys.argv[1]
|
|
|
|
time_str = time.strftime('%Y.%m.%d,%H:%M:%S')
|
|
|
|
so = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
|
|
so.connect((host, port))# 连接服务器端
|
|
data = so.recv(1024)# 接收数据
|
|
print(f"get message: {data}")
|
|
so.send(b'user '+username.encode()+b" ")# 发送用户名
|
|
so.recv(1024)
|
|
print("s1")
|
|
|
|
so.send(b'time '+time_str.encode()+b" ")# 发送文件名
|
|
so.recv(1024)
|
|
print("s2")
|
|
|
|
|
|
so.close()# 关闭连接
|