• 0

[C#] Basic File Sending


Question

3 answers to this question

Recommended Posts

  • 0

Well, first, you seem to have a perspective problem. It's a basic task, but that doesn't necessarily mean "simple."

Several ways you could do it. You could implement a webservice on the server and have the client pass the data that way (that's probably the simplest way to do it, but also the most verbose in terms of web traffic), you could manually open a socket on the client and implement a TcpListener on the server (the most difficult, but also the most efficient), you could use HTTP to transfer back and forth, or you could be more eccentric and use FTP.

The "best way" really depends what you're trying to do. If it's a small amount of data you're looking to transfer, making things easier on yourself and using a webservice would probably be best. If you're looking at lots and lots of data or lots and lots of clients, doing everything manually with sockets is harder to do, but it's "best" in that case because it's easier on the connection; FTP would also be good in that case (it was designed to transfer larger amounts of data than the other available protocols), but it's also going to be much harder to implement -- unless you buy an FTP component.

  • 0

There isn't really a clear cut answer in that case. FTP would be too cumbersome for lots of small files like that. Sockets, of course, would give the best performance, but you need to evaluate whether you need that or not. If your machine can handle that much traffic coming in, plus the processing power needed to unpack the data when it gets to the server, plus whatever processing you're doing on the files to begin with, then go with a webservice. If you've already got the machine doing a lot of data crunching, then sockets would be better.

Alternately, you might want to try HTTP, since it was designed for that type of scenario (lots of small files, in lots of requests). In that case, I would have each client log into the server, and have the server sent HTTP requests to the clients every minute. (have the server pull the data from the clients rather than the clients pushing the data to the server)

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.