Android Question Lost wifi connections and reconnecting again automatically

mbatgr

Active Member
Licensed User
Longtime User
Good morning to all. I have an serious issue with broken wifi connections and reconnecting client (B4A app) again with the server to continue the smooth operation of the app (using socket library). Is it possible for someone colleague to share a bit of another useful code here? I think that given the limitations of socket.library this is an important general issue that most members of this group would like to manage efficiently.
 
Last edited:

mbatgr

Active Member
Licensed User
Longtime User
Trying to check and control what Troberg said but I thing I have already manage to unblock it using the
suggestion of member rbsoft during a past communication.
B4X:
Public Function ServerSendData(Index As Integer, pstrSendData As String)


        If wsClients(Index).State = 7 Then
            wsClients(Index).SendData pstrSendData & Chr$(4)
    
            LogList(Index).AddItem "S: [" & pstrSendData & "]"
    
            DoEvents ' important: * Not to lock the PC
                     '            * There seems to been a bug with winsock.
        End If

End Function

On the other hand, I use timers to both modules so when either a server/client response delay more than 10 sec to re-send the last message and log it in a file. I really think that is not a broke connection but I would manage to solve that case, just in case.
 
Last edited:
Upvote 0

mbatgr

Active Member
Licensed User
Longtime User
I'm experimenting with different causes to lost a connection. When I'm connecting to the server and close the B4A application (by dragging its screen on the left), the connection lost, and the server remove that client number. However when i turn off the tablet's wifi, the A_streams_error fires and then I try to exit the application (socket.close, exitapplication)...but this time the server does not recognise that the connection is lost. How can emulate the closing application as it happens on activity_pause(userclosed)?
 
Upvote 0
Top