anthony.selby
Well-known member
- Joined
- Sep 3, 2009
- Messages
- 65
- Programming Experience
- 5-10
I'm trying to send a XML serialized class over a network stream
the send is working
When I recieve it I and convert it back to a object with this
I always get an error {"Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host."} The XMLFile has the xml document in it most of the time and I can go on and everything works but 1 out of every 5 times it doesn't work at all and the XMLFile contains nothing ... does anyone know whats going on ? I've googled for a while I don't see anything that will help.
Thanks
the send is working
VB.NET:
Dim IP As Net.IPAddress = System.Net.IPAddress.Parse(IPAddress)
Dim IPE As New Net.IPEndPoint(IP, 10003)
Dim TCPClient As New Net.Sockets.TcpClient
Dim MS As New IO.MemoryStream
Dim IPn As System.Net.Sockets.NetworkStream
TCPClient.Connect(IPE)
IPn = TCPClient.GetStream
TCPXS.Serialize(MS, Message)
MS.Position = 0
Dim XMLDocument As New Xml.XmlDocument()
XMLDocument.Load(MS)
XMLDocument.Save(IPn)
IPn.Flush()
When I recieve it I and convert it back to a object with this
VB.NET:
TCPListen.Start()
Dim TClient As Net.Sockets.TcpClient
Dim TStream As Net.Sockets.NetworkStream
TClient = TCPListen.AcceptTcpClient
TStream = TClient.GetStream
'Dim XmlReader As New Xml.XmlTextReader(TStream)
Dim XMLFile As New Xml.XmlDocument
Try
XMLFile.Load(TStream)
Catch exp As Exception
'ERROR HERE
End Try
XMLFile.Save(MS)
MS.Position = 0
TempSendPatientStructure = CType(TCPXS.Deserialize(MS), SendPatientStructure)
I always get an error {"Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host."} The XMLFile has the xml document in it most of the time and I can go on and everything works but 1 out of every 5 times it doesn't work at all and the XMLFile contains nothing ... does anyone know whats going on ? I've googled for a while I don't see anything that will help.
Thanks