realblue Member Licensed User Longtime User Jul 14, 2014 #1 Hi everybody. I am using the VB code below to compress some information in order to send trough UDP : Code: Copy Public Shared Function Compress(ByVal data As Byte()) As Byte() Dim ms As New MemoryStream() Dim ds As New DeflateStream(ms, CompressionMode.Compress) ds.Write(data, 0, data.Length) ds.Flush() ds.Close() Return ms.ToArray() End Function When I receive the bytes I decompress as shown below : Code: Copy DeflateStream(ms, CompressionMode.Decompress, True) This method is fine as long as receiving party is a Windows client. But I need to implement an Android client that listens to UDP port as well and process received information. So how can I convert this piece of code to B4A or is there another common library that I can use it both Windows and Android? Thanks in advance.
Hi everybody. I am using the VB code below to compress some information in order to send trough UDP : Code: Copy Public Shared Function Compress(ByVal data As Byte()) As Byte() Dim ms As New MemoryStream() Dim ds As New DeflateStream(ms, CompressionMode.Compress) ds.Write(data, 0, data.Length) ds.Flush() ds.Close() Return ms.ToArray() End Function When I receive the bytes I decompress as shown below : Code: Copy DeflateStream(ms, CompressionMode.Decompress, True) This method is fine as long as receiving party is a Windows client. But I need to implement an Android client that listens to UDP port as well and process received information. So how can I convert this piece of code to B4A or is there another common library that I can use it both Windows and Android? Thanks in advance.
Erel B4X founder Staff member Licensed User Longtime User Jul 15, 2014 #2 You can deflate the stream with CompressedStreams from RandomAccessFile library. You can implement the windows app with B4J and then reuse the same code. Upvote 0
You can deflate the stream with CompressedStreams from RandomAccessFile library. You can implement the windows app with B4J and then reuse the same code.