socket in PPC & Android

konisek

Member
Licensed User
Longtime User
I need to send a "AAAA010000000004000159" via network.

In PPC version I do it in this way:
Client.New1
Client.Connect(IP,30704)
bin.New1(Client.GetStream,False)
...
Dim Byt1(11) As byte 'AAAA010000000004000159
Byt1(0)=170
Byt1(1)=170
Byt1(2)=001
Byt1(3)=000
Byt1(4)=000
Byt1(5)=000
Byt1(6)=000
Byt1(7)=004
Byt1(8)=000
Byt1(9)=001
Byt1(10)=089
bin.WriteBytes(Byt1())


In Android version I tried:
Dim Socket1 As Socket
Dim AStreams As AsyncStreams
Socket1.Initialize("Socket1")
Socket1.Connect(IP,30704,3000)
AStreams.InitializePrefix(Socket1.InputStream, False, Socket1.OutputStream, "AStreams")
...
Dim Byt1(11) As byte 'AAAA010000000004000159
Byt1(0)=170
Byt1(1)=170
Byt1(2)=001
Byt1(3)=000
Byt1(4)=000
Byt1(5)=000
Byt1(6)=000
Byt1(7)=004
Byt1(8)=000
Byt1(9)=001
Byt1(10)=089
AStreams.Write(Byt1())

Android code is not working. Can you tell what wrong is with it?
 

derez

Expert
Licensed User
Longtime User
As Erel explains in the Astream Tutorial
If you can work in prefix mode, which is usually only possible if you are implementing both sides

Try it with the regular mode.
 
Last edited:
Upvote 0

konisek

Member
Licensed User
Longtime User
correct code is
AStreams.Initialize(Socket1.InputStream, Socket1.OutputStream, "AStreams")

and mainly:
AStreams.Write(Byt1)
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…