![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
|
i'm trying to send some xml data over a socket, and then receive a reply from the server. I've been doing it like this: 'client: dim xmldoc as new XmlDocument '...(make the xml up) dim t as New TcpClient() t.Connect(host,port) 'connects ok... dim thestream as NetworkStream = t.GetStream() xmldoc.Save(thestream) dim responsedoc as new XmlDocument() 'the next bit is where it gets stuck... responsedoc.Load(thestream) 'server: dim thelistener as new TcpListener(IPAddress.Loopback, port) thelistener.Start() dim theclient as TcpClient = thelistener.AcceptTcpClient() dim thestream as NetworkStream = theclient.GetStream() dim recdxmldoc as new XmlDocument() recdxmldoc.Load(thestream) 'only completes if the client disconnects...? now this all works fine if the client disconnects as soon as it has sent the document, i.e. if it closes the stream and client instead of the bit following where i've put 'the next bit is where it gets stuck'. But my problem is that if the client tries to receive data back from the socket, then the client blocks on responsedoc.Load, and the server blocks on recdxmldoc.Load. I think what I need is some way of the client saying "over" but not "over and out". How do I do this please? I tried doing thestream.Close() on the client, but then when I tried to read from it, it throws an exception telling me I cannot perform this action on a disposed object. I've also not changed the client from its default of 'doesn't own socket'. I presume that's right? Cheers for any help |
#2
| |||
| |||
|
|
I don't understand what you mean. LoadXml takes an xml string as a parameter, so how can I pass the size of the data to be sent? "Ivar Lumi" wrote: Hi, What about implementing commnd like: clinet: LoadXml size_of_data_to_be_sent<CRLF server: OK send data<CRLF client: sends data server reads size_of_data_to_be_sent server: OK<CRLF this ensures that all data is sent, and you see result always. "Ben" <Ben (AT) discussions (DOT) microsoft.com> wrote in message news:17B05A64-7009-4A67-AA1E-2B388DCA2275 (AT) microsoft (DOT) com... i'm trying to send some xml data over a socket, and then receive a reply from the server. I've been doing it like this: 'client: dim xmldoc as new XmlDocument '...(make the xml up) dim t as New TcpClient() t.Connect(host,port) 'connects ok... dim thestream as NetworkStream = t.GetStream() xmldoc.Save(thestream) dim responsedoc as new XmlDocument() 'the next bit is where it gets stuck... responsedoc.Load(thestream) 'server: dim thelistener as new TcpListener(IPAddress.Loopback, port) thelistener.Start() dim theclient as TcpClient = thelistener.AcceptTcpClient() dim thestream as NetworkStream = theclient.GetStream() dim recdxmldoc as new XmlDocument() recdxmldoc.Load(thestream) 'only completes if the client disconnects...? now this all works fine if the client disconnects as soon as it has sent the document, i.e. if it closes the stream and client instead of the bit following where i've put 'the next bit is where it gets stuck'. But my problem is that if the client tries to receive data back from the socket, then the client blocks on responsedoc.Load, and the server blocks on recdxmldoc.Load. I think what I need is some way of the client saying "over" but not "over and out". How do I do this please? I tried doing thestream.Close() on the client, but then when I tried to read from it, it throws an exception telling me I cannot perform this action on a disposed object. I've also not changed the client from its default of 'doesn't own socket'. I presume that's right? Cheers for any help |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |