I would like to know if the receiving socket received and processed the data sent and throw an error if not.
My problem comes when calling .receive (or as below) to check for an ACK from the client. E.g. the .BeginReceive catches the message.
I would like to use code like below
Expand|Select|Wrap|Line Numbers
- Dim ns As New NetworkStream(RemoteSocket)
- '_NetworkStream.WriteTimeout = 10000
- '_NetworkStream.ReadTimeout = 10000
- Dim strResponse As String
- ' Send a string (newline terminated) to the server.
- Dim writer As New System.IO.StreamWriter(ns)
- Dim reader As New System.IO.StreamReader(ns)
- writer.Write(Message)
- writer.Flush()
- ' Read server response (up to a newline).
- Try
- strResponse = reader.ReadLine
- Catch ex As Exception
- 'Thorw error, report back send problem
- strResponse = Nothing
- End Try
- 'Close
- writer.Close()
- reader.Close()
- ns.Close()
- Return strResponse
- Catch ex As Exception
- Return Nothing
- Finally
Any sugguestions, I understand you can’t cancel a .BeginReceive but can you override it?