Android Question [Solved] Problem with AsyncStreams in prefix mode.

JoanRPM

Active Member
Licensed User
Longtime User
Hello.
In a project I use android as TCP Client and VB6 as TCP Server.
I use the AStreams in prefix mode to send pictures to the Client (Android).
The problem is that, once connected, can only send/receive one transmission (one picture). To send another picture, I need to stop and connect again the Socket.
The bytes transmited by the server are always the same, and in VB6 I include the correct prefix. So the Android Client only receive the first transmission.
In the example, you can click either in the server or in the client, to display one of the two pictures.

In the attached files there are a B4A source and a PC Server executable program.

Anyone know what could be the problem?

Greetings.
 

Attachments

  • TcpClient.zip
    7.8 KB · Views: 183
  • TcpServer.zip
    9 KB · Views: 146

mc73

Well-Known Member
Licensed User
Longtime User
Ah, thanks to Rusty, I now saw that you uploaded your vb6 code. One error that I found was in your sendFile sub
B4X:
 Winsock1(1).SendData (xxx)
You should instead use the index of the connected socket instead of always 1. This should err since once you open a new connection, your sub still tries to send data to a previous one. In order to do this, include in your sub's parameter's the winSocket's index and then
B4X:
 winSock1(selectedSocket).sendData(xxx)
 
Upvote 0

JoanRPM

Active Member
Licensed User
Longtime User
No, it dosen't work.
In my example, the variable "selectedSocket" is always 1.
In my final program, I use this variable to control if there is more than one connection at the same time.
So, the problem is not solved.
Thanks again.
 
Upvote 0

coslad

Well-Known Member
Licensed User
Longtime User
Hi ,

I found the problem , you send a not necessary byte , i attach your working source code , now works like a charm.

In the VB6 i added this

B4X:
ReDim Preserve xxx(UBound(xxx) - 1) As Byte

And in B4A code i changed this:

B4X:
In.InitializeFromBytesArray(aux, 0, aux.Length)

in this :

B4X:
In.InitializeFromBytesArray(aux, 0, aux.Length-1)


Use like button ;)
 

Attachments

  • tcpserver.zip
    13.4 KB · Views: 157
  • TcpClient.zip
    291.4 KB · Views: 172
Upvote 0
Top