Problem: if the wifi network has a problem and the b4a tcp/ip socket does not reset then How do I reset the socket?  the Pingserver does not reacquire the network after failing.
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
			
			
			
				B4X:
			
		
		
		sub Class_Globals
   dim myLan as serversocket
end sub
Sub ServerSocket1_NewConnection(Successful As Boolean, NewSocket As Socket)
End Sub
Sub PingServer As Boolean
    Dim bRetVal As Boolean=False
    If myLan.IsInitialized=False Then
        myLan.Initialize(0,"ServerSocket1")
    End If
    Dim oMLWifi As MLwifi
    If oMLWifi.isOnLine=False Then
     'Try other apis below and see if they can get past the socket problem.       
    Else
        ReturnTrue
    EndIf
    Try
        'Case 1
        Dim oPhone As Phone
        If oPhone.IsAirplaneModeOn=True Then
            bRetVal=False
            Return(bRetVal)
        End If
        Dim sDeviceIP As String
        'Check 4G connectivity
        sDeviceIP=myLan.GetMyIP
        If sDeviceIP<>"127.0.0.1" Then
            bRetVal=True
            Return(bRetVal)
        End If
        sDeviceIP=myLan.GetMyWifiIP
        If sDeviceIP<>"127.0.0.1" Then
            bRetVal=True
            Return(bRetVal)
        End If
        If oPhone.GetSettings("wifi_on")<>1 Then
            bRetVal=False
            Return(bRetVal)
        End If
        If oPhone.GetDataState="DISCONNECTED" Then
            bRetVal=True
        Else
            bRetVal=False
        End If
    Catch
        oError.ShowLastException("Error Ping")
    End Try
    Return(bRetVal)
End Sub
			
				Last edited: 
			
		
	
								
								
									
	
								
							
							 
				 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		