The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Direct file transfer program

Hi all,

I want to write an app that allows two people to quickly and easily transfer files between each other (something like directIM in AIM and GAIM). The motivation behind this program is that I hate setting up a ftp server, or attaching to emails when all I want to do is send a small file.

I've done some simple network programming here in college (basic TCP/UDP socket stuff) so I want to know if there is any more that is required for entire file transfers?

I'm also planning to do this in ruby (since it seems to be the talk of the town). Does anyone have any experience with this sort of application (in any language really, but Ruby specifically).

There's a buddy of mine who was talking about doing something similar

A buddy of mine was talking about doing something similar to what you're talking about. I think it is pretty much as simple as what you're thinking. The only thing you would want to be wary of are firewall issues, but if the ftp solution is already working for you, then that probably isn't a problem.

It sounds like you have ruby on both ends? If so one solution would be to use webrick, a pure ruby web server that is in ruby's standard library. You can get more info here: http://www.webrick.org/. Here is an example of how easy it is to create a simple http server:

This way you could run a webrick server on each computer and transfer files easily with curl or a web brower. Or if you want to keep it pure ruby use open-uri for the client side of the transfers. Here is an example of open-uri:

And then if you want to flesh things out a bit, the webrick servelet will give a directory listing if you don't specify a file. You could have you client get a listing of available files and ask them on the command line for the name of the file they want. Then use that filename fo rhte open-uri request and the file.write and you would have a pretty cool system~

It sounds like you have ruby on both ends? If so one solution would be to use webrick, a pure ruby web server that is in ruby's standard library. You can get more info here: http://www.webrick.org/. Here is an example of how easy it is to create a simple http server:

This way you could run a webrick server on each computer and transfer files easily with curl or a web brower. Or if you want to keep it pure ruby use open-uri for the client side of the transfers. Here is an example of open-uri:

Well, I leave that as an excercise to the user . Seriously though, you might wnat to consider using xml-rpc on both ends. Its fairly easy to do with ruby and there is some security built into that protocol. And you can send files that way to after you base64 encode them.
But I guess I would like more information about the app you want to write before I can give much better response.

How difficult is it to use WxRuby? Is it possible to make a standalone exe, which is runnable on linux and windows? Sorry for noob questions.

I don't know anything about wxruby, so I can't comment on that, I have used rubytk and have found that to be an easy toolkit to learn and use, (and it has the benefit of working out of the box on both windows and linux).

for a standalone exe look for a gem called rubyscript2exe
this will make an exe with the ruby interpreter packeged in with the script. It's not really a compiler, but it does give you a single file that you can just run as though it were an exe. I believe if you want to distribute to both linux and windows, you will have to create two seperate files with rubyscript2exe, one for linux and one for windows.

PS, I've had more luck using rubyscript2exe on windows than linux, but I suspect this has to do with the fact I'm on unbuntu and am using the ubuntu packages which are configured strangely, if I had built ruby from scratch, I suspect this problem would disappear.