首页 > 编程语言 > 详细

[原创] python udt4 for windows recvfile.py

时间:2017-10-12 23:48:09      阅读:439      评论:0      收藏:0      [点我收藏+]
#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)

udt4py下载

[原创] python udt4 for windows recvfile.py

原文:http://www.cnblogs.com/tinyos/p/7658529.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!