Domanda

I am having trouble sending a propertybag over winsock. I have a client/server application that sends images through using a propertybag. I convert the propertybag into a byte array and try to send it over winsock and then when I convert the byte array back to a propertybag, it cant seem to read it. It looks like the data was corrupted when it was sent.

Client(sending propertybag)

Dim pb As PropertyBag
Dim byt() As Byte

Set pb = New PropertyBag

pb.WriteProperty "picc", Image1.Picture
byt = pb.Contents

Winsock1.SendData byt

Server(Receiving 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")

The error I received:

Run-time error '327':
Data value named 'picc' not found

When I try to do execute the code in a single program without winsock, it works just fine. The problem occurs when I send the byte array over winsock.

È stato utile?

Soluzione

Most people also utilize the ADO stream object (add reference to Microsoft ActiveX Data Objects 2.5 or whatever version) by going to Project -> References.

Here is a working example you can download using a PropertyBag as well as the ADO stream object.

It's called PicturePicture.zip and written by a very Winsock & client/server-knowledgeable programmer.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top