码迷,mamicode.com
首页 > 编程语言 > 详细

[原创] python udt4 for windows recvfile.py

时间:2017-10-13 00:33:50      阅读:276      评论:0      收藏:0      [点我收藏+]

标签:tiny   root   utf-8   blank   oca   soc   log   success   python   

#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

标签:tiny   root   utf-8   blank   oca   soc   log   success   python   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!