[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

sending files over a network

Pieter Breed

4/1/2006 10:18:00 AM

Hi All,

I am relatively new to Ruby and I am considering using it for a little
itch of my own I want to scratch. It deals with sending files over a
network, but in a one-computer-to-one-computer way, not swarming like
with torrents.

My question is two-fold: What is, in general, the better way of sending
files across a network like this. By better I mean appropriate for
files that may be both very long and very short? Some error checking
also needs to be done so the files don't corrupt. I realise this is not
really ruby specific, but bear with me please.

How would you do/implement this in Ruby? If I was more familiar with
either Ruby or network programming I could probably bootstrap my
knowledge, but it seems I just don't know enough.

Regards,
Pieter Breed

9 Answers

f3l

4/1/2006 5:32:00 PM

0


Pieter Breed wrote:
> Hi All,
>
> I am relatively new to Ruby and I am considering using it for a little
> itch of my own I want to scratch. It deals with sending files over a
> network, but in a one-computer-to-one-computer way, not swarming like
> with torrents.

why not useing ftp?

>
> My question is two-fold: What is, in general, the better way of sending
> files across a network like this. By better I mean appropriate for
> files that may be both very long and very short? Some error checking
> also needs to be done so the files don't corrupt. I realise this is not
> really ruby specific, but bear with me please.
>
> How would you do/implement this in Ruby?

u dont need to, its been done for you before, lots fo times, just find
one implementation that suits your needs, and stick to it.

> If I was more familiar with
> either Ruby or network programming I could probably bootstrap my
> knowledge, but it seems I just don't know enough.
>
> Regards,
> Pieter Breed

Pieter Breed

4/1/2006 10:12:00 PM

0

Uhm, thanks... I didn't think of that...

actually I really meant to ask what I asked in the first place... Sorry
for being bitchy, but I your answer was kind of silly.

Pieter

Ara.T.Howard

4/1/2006 10:31:00 PM

0

Konstantin Levinski

4/2/2006 3:54:00 PM

0

If you know how to work with files, and how to set up connections
(TCPServer/TCPSocket) you know enough to send a file over network with
Ruby. Performance will be network-limited, so don't worry too much
about it.

You can use MD5/SHA1 for additional error checking, for error checking,
tough TCP has this feature on its own.

pseudocode ( as in - not tested but with a couple of fixes should
probably work )

- sender:
name="file.txt"; len = File.new(name).stat.size.to_s
socket = TCPSocket.new('remote.host.org', 6666)
socket.puts name
socket.pits.len
socket.write File.read(name)
socket.close

- reciever:
socket = TCPServer.new('0.0.0.0', 6666).accept
name = socket.gets
len = socket.gets
File.open(name, "wb") { | fl | fl.write (socket.read len.to_i ) }
socket.close
---

HTH

Pieter Breed

4/2/2006 8:11:00 PM

0

Thanks Konstantin, that is really helpful and I will give it a bash

Regards,
Pieter

Konstantin Levinski

4/3/2006 9:09:00 AM

0

btw, depending on your requirements you might want to have a look at
http://rio.ruby... -
it gives IO, File, Dir and sevral others a simple consistent interface
- in case you want to work with directories and files and a lot

Douglas Mcneely

2/13/2013 10:48:00 PM

0

Real name Fwanklin. Fwanklin is a famous homo. Fwanklin's 15 seconds
of fame came at a Star Trek Convention when he embarrassed the
audience, embarrassed America, embarrassed humanity and embarrassed
Gene Roddenberry by asking why Star Trek didn't have any faggot
characters. Fwanklin, after many beatings, has become just another
cock-slapped usenet zoo monkey. Liars, once they have been exposed,
frequently revert to behavior most similar to a zoo monkey who sits in
the cage throwing feces at passersby but saying nothing of value.

Franklin Hummel - born May 1953
18 Linwood St, Unit 3
Boston, Massachusetts 02119-1543
(617) 541-3834
E-mail: hummel@world.std.com
Possible Fag Butt-Buddy: Arnold D Thomas (Age 52)

Franklin Hummel - Supervisor
Boston Public Library
700 Boylston Street
Boston, Massachusetts 02116
(617) 536-5400
(617) 536-3813 Fax
www.bpl.org

http://www.zoominfo.com/people/Hummel_Franklin_611...

[][][][][][]


The DemocRAT Hall Of Shame http://www.democrathallof... asks
"Why do you always LIE?"

[Courtesy of Buster Norris]

On Fri, 25 Jan 2013 15:22:37 -0800 (PST), "Tom Sr."
<thomas.swift.senior@gmail.com> wrote:
>No, Faux News tossed her ass off.

LIAR!!!!!!!!!!!!!!!!!!!!!!

?It?s my understanding that Gov. Palin was offered a contract by FOX,
and she decided not to renew the arrangement,? the source close to
Palin told RCP.
http://www.realclearpolitics.com/articles/2013/01/25/sarah_palin_parts_ways_with_fox_news_1...

Posted from:
The DemocRATs Hall of Shame!
http://www.democrathallof...

tomservo56954

2/14/2013 1:51:00 AM

0

On Tuesday, February 12, 2013 6:55:34 PM UTC-5, Tom Sr. wrote:
> On Feb 12, 6:48 pm, Tracey12 <tracey12em...@gmail.com> wrote:
>
> > Attention Republican Leaders:
>
> > YOU HAVE LEFT ME BEHIND BECAUSE YOU HAVE TURNED LEFT
>
>
>
>
>
> They have left you behind you and you ilk are irrational, bigoted
>
> KO0ks that are too fucking far-far-to-the-right of mainstream America
>
> -- and the Republican leaders are sick and tired of leading a party
>
> with losers like you in it, that drag the GOP as a whole into the
>
> political gutter.
>
>
>
> The GOP is waving "good-bye" to you, Tracey12, with its middle finger.
>
>

The problem is...those Republicans failed to legalize Tracey putting HIS middle finger--or something of similar size--inside any middle school girl.

Paul

Aida Trinidad Christensen

2/14/2013 11:23:00 PM

0

Yoorghis: Real name Gary Richard Roselles. Before he was exposed he
changed his name every few days or weeks mainly because he's a
sociopathic coward, a pussy, and above all else a LIAR and a
time-waster. Gary is another example of a Complete Loser: He is
festering away in a one-bedroom apartment on Medicaid and Social
Security having wasted his entire life...

Gary uses "X-No-Archive: yes" in his message Header to force
server-side deletion of ALL of his posts and this is usually the only
way to detect his presence (unless you detect the strong odor of
shit).

Note that when you reply to a Proven Liar you encourage them to
continue lying.

Gary Richard Roselles (68+)
Diane M Roselles (52+)
4215 Cedar Ridge Pl, Apt 42
Rapid City, SD 57702-3190
(605) 341-2445

[][][][][][]
The DemocRAT Hall Of Shame http://www.democrathallof... asks
"Why do you always LIE?"

[Courtesy of Buster Norris]

On Fri, 01 Feb 2013 10:35:31 -0700, Yoorghis@Jurgis.net wrote:
>By 2009---60,000,000 w/o Health care

LIAR!!!!!!!!!!!!!!!!!!!!!!!!

32.8 million (10.9%) had been uninsured for more than a year at the
time of interview.
http://www.cdc.gov/nchs/data/nhis/earlyrelease/insur...

Posted from:
The DemocRATs Hall of Shame!
http://www.democrathallof...