473,320 Members | 1,883 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Send and receive XML using tcpclient

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?
Nov 21 '05 #1
1 4269
Anyone?

"Philip Wagenaar" wrote:
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?

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: zhimin | last post by:
Hi, I'm writing a program to send large file(100m) through dotnet using TCPListener & TCPClient, I'm sending the file with a ask and response loop: 1. Client send a flag 1 to server indicate it...
6
by: John J. Hughes II | last post by:
I have a service that needs to send e-mail alerts. I have been attempting to use the System.Net.Mail function from .NET but this seems to require the IIS be installed and running. Since some of...
1
by: Matt | last post by:
We have an Intermec stationary computers setup to basically clock people in and out... I have code running (borrowed from Planet Source Code and modified to suit) to receive packets from these...
3
by: BuddyWork | last post by:
Hello, Could someone please explain why the Socket.Send is slow to send to the same process it sending from. Eg. Process1 calls Socket.Send which sends to the same IP address and port, the...
0
by: Buddy Home | last post by:
There is two examples of code. Example 1. Send and Receive within the same process. Put this code in a console app called SendAndReceive and run the code. using System; using...
14
by: eliss.carmine | last post by:
I'm using TCP/IP to send a Bitmap object over Sockets. This is my first time using C# at all so I don't know if this is the "right" way to do it. I've already found out several times the way I was...
0
by: ChopDown | last post by:
Hi, I want to send/receive a serializable object in socket: ==========sender========== Dim MyMessage As New MessageClass.Message() Dim client As New TcpClient...
5
by: Markgoldin | last post by:
I am searching for a solution of sending messages from not .Net process into a .Net process written in C#. I have gone already thru sockets solution and have porblems with it. I am not a C# coder...
1
by: secutos | last post by:
When a TcpListener accepts a connection, it returns a TcpClient, which allows you to recieve data. But what about TcpListener.Server.Receive? Does that also allow to receive data in the same way? Or...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.