[原创] python udt4 for windows recvfile.py

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[原创] 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)

udt4py下载

以上是关于[原创] python udt4 for windows recvfile.py的主要内容,如果未能解决你的问题,请参考以下文章

[原创] python udt4 for windows sendfile.py

First order of polyurethane resin for wind blades

[原创]K8Cscan for Python 2.0

python [IO] wind引入代码及股票名#tags:wind,code

python气象绘图windrose

想在wind中试验python接口,该怎么做到