removed
Printable View
removed
bump
To be more specific on my problem, after researching around a little. I realise it's recieveing a null reference when looking to stream because the client is no longer there, however it's still looking for something.
Now I tried to add a check like:
vb Code:
If networkStream.CanRead Then Bla bla bla carry on then Else Dont do it End If
However it's still not working correctly, I dont understand why its still looking for a network stream. Is their any other way around this to avoid getting a system.nullreference object error when a client forcibly closes?
Thanks
A crash is just an unhandled exception. There's nothing specifically wrong with exceptions, so just handle it and there's no crash. You might like to follow the CodeBank link in my signature and check out my Asynchronous TCP thread. You'll see that there are various places where pending asynchronous calls will cause exceptions to be thrown, so I just catch those exceptions and the app carries on.
Thanks for the reply,
As you can read in the doChat() part of the server there is a catch statement
Catch ex As Exception
MsgBox(ex.ToString)
however it's obviously not working well. I looked over at how if bytes = 0 then disconnect user, however wouldn't you still crash at attempting to read the stream?
If you are catching an exception in one place and the app is still crashing then that exception is obviously being thrown elsewhere, so your Catch block is either in the wrong place or you need another. You need to catch exceptions in all places that they can reasonably be thrown. If you check out my code you'll see Catch blocks in various places.