Question

I'm working on a tool which would need to communitacte: send and recieve files with other remote instances of the tool over the internet. Which communication option would be best to use in this case ? Sockets?

Was it helpful?

Solution

Sockets is definitely not the way to go. Instead you should use an already existing, higher layer protocol, like FTP or even HTTP. Sockets only expose bare TCP/IP functionality. So to send/receive files, you would end up adding the application logic yourself (you need to deal with lost packets for example). Higher layer protocols already do this for you.

OTHER TIPS

One point about HTTP is that good, mature and (to a greater or lesser extent) security audited HTTP client and server libraries are available for pretty much any language or platform. This will save you the effort of building and debugging your own, and security is a significant issue if the HTTP servers could be exposed to the public internet.

EDIT: For C#, you might try Windows Communication Foundation which also supports higher level protocols.

It depends a lot on the environment they are operating in. TCP Sockets are quite straight forward to use as long as you check your reads and writes are successful. However you may have some trouble with firewalls, or you may not want to deal with a stream of raw bytes at each end, in which case a higher level protocol such as HTTP or FTP might be a better solution.

It also depends on which language you're working in and what support is given for particular protocols in its libraries.

You shouldn't expect to be able to make inbound connections to arbitrary machines all over the internet - firewall policies will almost certainly get in the way.

Therefore you're probably better off having a central server to which all instances of the tool connect, and to which files can be uploaded for subsequent download by other instances.

As per other answers, I wouldn't recommend a low-level socket connection. HTTP would probably be the right way to go.

From your comments on the other answers it sounds like you are confusing the file transport with the file encryption. As others have pointed out, you could use HTTP or FTP to transfer the files. HTTP already works over SSL which can authenticate the server, encrypt the traffic and (with a bit more work) authenticate the client.

If you want the files themselves to be encrypted as well, your best bet is again to use something that already exists, e.g. PGP (or an implementation of it such as GPG). You could also look at S/MIME but PGP will be simpler. If you reinvent your own encryption there are too many pitfalls that you will find difficult to avoid.

If all you're needing is simple file transfer between instances, I'd suggest looking into any available tftp client/server libraries for your language.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top