cancel
Showing results for 
Search instead for 
Did you mean: 

Byte Array

Former Member
0 Kudos

Dear all,

Does anyone has experience using DART ActiveX (udp), in receive event it tells to use byte array, how to do this in PB 11.5.

The samples that their give is VB. In VB they just using "Udp1.Receive s  ' receive data into string ". I write in PB "ole_udp.object.receive(s)" //s is string datatype but this script return me an empty string. I Look up to the help file and find that this function must use byte array.

I'm not familiar with 'byte array' and how to declared it.

Can anyone help.

TIA

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Eko,

Here's some sample code I have in a PB WCF web service that declares and uses a byte array along with a file and memory stream for a PDF file that gets sent back to a PB client as a blob.

System.IO.FileStream filestream

System.IO.MemoryStream memStream

byte lb_byte_array[]

// create a file stream based on the new pdf file

fileStream = create FileStream(ls_result, System.IO.FileMode.Open!, System.IO.FileAccess.Read!, FileShare.Read!)

   

// create a memory stream

memStream = create MemoryStream

   

// copy the filestream to the memory stream

fileStream.CopyTo(memStream)

   

// allocate space in the byte array for the memory stream

lb_byte_array = create byte[System.Convert.ToInt32(memStream.Length)]

   

// copy the memory stream to the byte array

lb_byte_array = memStream.ToArray()

   

return blob(lb_byte_array)

hth,

Mark

Former Member
0 Kudos

There is the Byte and Blob datatypes that might work.

I have an example of using socket functions directly from PB without using an ActiveX control. It might work better for you.

http://www.topwizprogramming.com/freecode_winsock.html

Roland

Former Member
0 Kudos

Thanks for your reply,

I've already try one of your sample but there is something different with my need.

I want to build a little program (something like gateway) that listen at port 7912 and send a response to a spesific ip on port 8231. For example my pc ip 192.168.1.1 and MUST response to server ip 192.168.1.50(port 8231) through port 7912.

When using 'your sample' and wireshark to monitor incoming/outgoing packet, I found in the 'info' column says packet that I send is correct destination port (8231) but the source port is not from port 7912 (it give 'something' dynamically change/different value every time I send a packet).

When I used DART component (sample) and send some packet to server the source port (7912) and destination (8231), and the server can respone to my packet.

How to make your UDP sample send a packet from a spesific port (as source port) to a spesific port (as destination port)?

Thanks

Former Member
0 Kudos

I uploaded a new version of my Winsock example. The of_SendTo function now has optional FromPort argument. I haven't had a chance to test it. I would appreciate it if you could give it a try and check it with Wireshark to make sure it is working correctly.

The UDP Send tabpage object is unchanged so uses the override with only SendPort.

There are now two forms of the function:

of_SendTo(IPAddress, FromPort, SendPort, Data)

of_SendTo(IPAddress, SendPort, Data)

Former Member
0 Kudos

Thanks Roland .. your "awesome" buddy! 

Former Member
0 Kudos

Thanks for your update, I will check your new sample with wireshark and post the result here.

Thanks