Send and receive XML using tcpclient

G

Guest

I have a server (tcp/ip) that receives and sends back XML.

When I use the following code to send a login xml string my application
hangs. I think it is waiting for somekind of notification that the return xml
string has ended.

Dim LoginXml As XmlDocument = New XmlDocument
LoginXml.Load("Login.xml")
Dim newClient As TcpClient = New TcpClient
newClient.Connect(TextBox2.Text, TextBox3.Text)
Dim tcpStream As NetworkStream = newClient.GetStream
Dim xmlFile As String = LoginXml.OuterXml
Dim sendBytes() As Byte = Encoding.UTF8.GetBytes(xmlFile + "\r\n")
tcpStream.Write(sendBytes, 0, sendBytes.Length)
Dim strReader As streamreader = New
StreamReader(newClient.GetStream())
Dim returnData As String = strReader.ReadLine()
LoginXml.LoadXml(returnData)
Dim filename As String = "response.xml"
LoginXml.Save(filename)

Where am I going wrong?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

NNTP Client 4
TCP Transfer issues 3
How to debug this? 10
sending xml over tcp/ip 7
send file 1
Testing client server application from single computer 3
a simple client example 3
Data Logger 1

Top