DX 8.1 SDK Peer2Peer and AddDataToBuffer function
First i just wanna say I'm sorry for this very long thread and hope you take the time to help me...
I use the 8.1 SDK for Visual Basic 6.
My program is almost finished i just need one last function and that is to send Jpgs pictures over the peer2peer connection...
I've opened the jpeg as binary but i cant for love of god find a way to send the packages.
I've devided the jpeg into packets of 512 bytes each. First i tried to send them with the "AddStringToBuffer" function like this...
*********************************
Dim lOffset As Long
Dim oBuf() As Byte
lMsg = MsgSendJPG
lOffset = NewBuffer(oBuf)
AddDataToBuffer oBuf, lMsg, LenB(lMsg), lOffset
AddStringToBuffer oBuf, sData, lOffset
dpp.SendTo DPNID_ALL_PLAYERS_GROUP, oBuf, 0, DPNSEND_NOLOOPBACK
********************************
It seems that the sendstring function cant handle all charachters in the packege so the final size of the jpeg isnt the same as it was when I sent it. Ok so i figured out that what i need to do is to use the AddDataToBuffer. I've tried out the SDK DataRelay examples, but they only send the packet size. I tried to add a data string to the PacketInfo type like this
Private Type PacketInfo
lPacketID As Long
lDataSize As Long
sData as String 'This is the line i added
End Type
Then i tried to send a package containg only chr(32) (space) like this,
Private Sub Command1_Click()
Dim lMsg As Long, lOffset As Long
Dim oPacket As PacketInfo
Dim mlSize As Long
mlSize = 512
lMsg = MsgSendJPG
lOffset = NewBuffer(moBuf)
AddDataToBuffer moBuf, lMsg, LenB(lMsg), lOffset
oPacket.lPacketID = 1
oPacket.lDataSize = mlSize
oPacket.sData = Space(512)
AddDataToBuffer moBuf, oPacket, LenB(oPacket), lOffset
ReDim moByte(mlSize)
AddDataToBuffer moBuf, moByte(0), mlSize, lOffset
dpp.SendTo DPNID_ALL_PLAYERS_GROUP, moBuf, 5, DPNSEND_NOLOOPBACK Or DPNSEND_NOCOPY
End Sub
The Client recives the oPacket.lPacketId = 1
and the oPacket.lDataSize = 512 but it does not recive my
oPacket.sData
Shouldnt i declare the data variable as a string?
How should this be done?
/Anders
Hi, I'm only new at network programming myself, but I believe DX8.1 has a packet object called NetworkPacket.
Try creating a new NetworPpacket object.
Then using: packet.Write(jpgorwhatever)
The write command automatically converts the passed object into raw bytes which can then be reaquired on the other side with something like this (this is in C# but the concept should be the same):
In DX8.1's recevie handler.
Try creating a new NetworPpacket object.
Then using: packet.Write(jpgorwhatever)
The write command automatically converts the passed object into raw bytes which can then be reaquired on the other side with something like this (this is in C# but the concept should be the same):
JpgObject jpg = (JpgObject) args.Message.ReceiveData.Read(typeof(JpgObject));
In DX8.1's recevie handler.
Strange i cant find that Object in the readme.. Maybe its not avaible in VB.... But there must be a way to send data using the AddDataToBuffer
and
GetDataFromBuffer
i've found an example code that does send a file using these two commands. But they have so much other code so its really hard to find wants relevvant for the send file part and whats not..
and
GetDataFromBuffer
i've found an example code that does send a file using these two commands. But they have so much other code so its really hard to find wants relevvant for the send file part and whats not..
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement