xunwichtig Member Licensed User Longtime User May 22, 2014 #1 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) Code: Copy 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
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) Code: Copy 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
Erel B4X founder Staff member Licensed User Longtime User May 22, 2014 #2 Such code doesn't work in Android. You cannot block the main thread. You should continue the program flow from Socket_Connected event (and make sure to use AsyncStreams). Upvote 0
Such code doesn't work in Android. You cannot block the main thread. You should continue the program flow from Socket_Connected event (and make sure to use AsyncStreams).
xunwichtig Member Licensed User Longtime User May 22, 2014 #3 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
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