Transfering Data

  • Thread starter Thread starter bernardpace
  • Start date Start date
B

bernardpace

Hi,

I am writing a client server application using TcpClient and
TcpListener classes.

Now I need to transfer structured large amounts of data. I was
thinking to transfer the data in an xml file, so that both on the
server and on the client side it would be easy to parse the data.

Now if I use the xml file, should the xml file be saved locally? Also
when transfering the xml file, what methods shoulds be used in the
TcpClient/TcpListener classes, ie Read() or Readline() or ReadToEnd(),
or some other appropriate method?


Can someone help me out
Thanks in Advance
 
If you wanna send file already existing there is no reason to create xml.

To send file use socket.sendfile() method.

If you use TcpListener remember that socket for valid connection is returned
by AcceptSocket.
If use TcpClient, property Client returns socket.

then only Sendfile.
If you have to receive file i recommend:

while ((bufferCount = CONNECTION.Receive(buffer)) > 0)

{

file.Write(buffer, 0, bufferCount);

}

where file is handle to file.



PK
 

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

Back
Top