Okay. That means maybe I found a bug... The Sender object in my code in streamData_Error is invalid and I got a crash if I reconnect after a successful connect. If I send data, then the streamData_Error has a valid Sender (AsyncStreams) and I don't get a crash when disconnecting.
Shorter:
a) Connecting->Disconnecting => invalid Sender/AsyncStreams in streamData_Error => CRASH
b) Connecting->SendData->Disconnecting => valid Sender/AsyncStreams in streamData_Error => FINE
Here The code snippet, the full project is appended. I marked my AsyncStream by setting the buffer to a well known value (here 101). But the log (reading this value) crashes.
Private Sub streamData_Error
Log("streamData_Error")
Dim TempAsyncStreams As AsyncStreams
Dim TempWiFiSocketWrapper As WiFiSocketWrapper
TempAsyncStreams = Sender
Log("MaxBufferSize: ", TempAsyncStreams.MaxBufferSize)
If StaticFixedTypeMap.Get(TempAsyncStreams, TempWiFiSocketWrapper) Then
Log("Gefunden!")
If TempWiFiSocketWrapper.EnclosedObject.Connected Then
TempWiFiSocketWrapper.EnclosedObject.Close
End If
TempWiFiSocketWrapper.EnclosedObject.Stream.Flush
StaticFixedTypeMap.Remove(TempAsyncStreams)
End If
wifiServerSocket.Listen
End Sub