[原创] python udt4 for windows recvfile.py
#coding: utf-8 import ctypes as _ctypes from ctypes import wintypes as _wtypes import threading import time import struct from udt4py import * fd = udt_socket() ret = udt_connect(fd,"127.0.0.1",9000) if ret == 0: print("connect success") else: print("connect fail") import os os._exit(0) filename = "/root/tinyos-main-master_20170930.zip" filename = "D:/1234.zip" # 发送文件名长度:int32 txlen = udt_send(fd,struct.pack("@I",len(filename)),4 ) print(txlen) # 发送文件名 filename=bytes(filename,"utf-8") txlen = udt_send(fd,filename,len(filename)) print(txlen) # 接收文件长度:int64 buf = udt_recv(fd) print("rxlen=",len(buf)) filelen = struct.unpack("@q",buf) print(type(filelen),filelen) localfilename = bytes("D:/1111.zip","utf-8") ret=udt_recvfile(fd,localfilename,filelen[0]) print("rx ok",ret)
联系方式:heshengjun@tinywsn.com