Android Question Wait Until Socket-Event

xunwichtig

Member
Licensed User
Longtime User
Hi.

I try to create a simple app to connect and send data. But, the connection must be created in the "send-data" function, if this is still not active.

(pseudocode)
B4X:
sub senddata()
if SocketStateVariable = 0 then
    socket.connect(...)
    do until SocketStateVariable = 1
        doevents
    loop
end if
socket.senddata
end sub

Well .. the problem is, that i never come out of the do-loop. I waiting for a value change of a SocketStateVariable. this value will change btw. set to 1 on "socket_connected()" event. But, this event looks never called while i'm in the do loop.

so. what i doing wrong here?


THX
JimJim
XUN
 

xunwichtig

Member
Licensed User
Longtime User
I use AsyncStreams for read and write ... but, i think thats the socket use a seperat thread, so that he can call the event and i can set the var to check the state. But, ok .. then i must do this on another way.

THX
JimJim
XUN
 
Upvote 0
Top