1
我无法通过winsock
发送propertybag
。我有一个通过使用propertybag
发送图像的客户端/服务器应用程序。我将propertybag
转换成一个字节数组,并尝试通过winsock
发送它,然后当我将字节数组转换回propertybag
时,它看起来似乎不能读取它。看起来数据在发送时已损坏。通过winsock发送包?
客户端(发送属性包)
Dim pb As PropertyBag
Dim byt() As Byte
Set pb = New PropertyBag
pb.WriteProperty "picc", Image1.Picture
byt = pb.Contents
Winsock1.SendData byt
服务器(接收的PropertyBag)
Dim byt() As Byte
Dim pb As PropertyBag
Set pb = New PropertyBag
Winsock1.GetData byt, vbByte
pb.Contents = byt
Image1.Picture = pb.ReadProperty("picc")
我收到的错误:
Run-time error '327':
Data value named 'picc' not found
当我尝试在没有winsock
的单个程序中执行代码时,它工作得很好。当我通过winsock
发送字节数组时发生问题。 >参考 -
我会写字节数组(发送和接收)到一个文件并比较差异 – Hrqls
一个'SendData'调用不能通过一个'GetData'调用可靠地接收。这是“数据包谬误”。您不会在用户定义的“数据包”中发送数据,而是发送流片段并接收长度不相同的流片段(并且每个数据到达事件的长度可能小至1个字节)。 TCP不是数据报协议。 – Bob77