Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: File Transfer via Sockets

by jryan (Vicar)
on Sep 14, 2002 at 19:56 UTC ( [id://197915]=note: print w/replies, xml ) Need Help??


in reply to File Transfer via Sockets

You should also look at Net::FTP.

If you really need to do it with straight sockets, stick with IO::Socket. It's much easier to use than Socket, and is also part of the core. To "transfer" a file via sockets, it would involve a process like this:

  1. From the sending side, connect to the recieving side.
  2. Send some sort of header to the recieving side, stating such like the file size, send chunk size, etc.
  3. The recieving side should recieve this, validate, and then send a response.
  4. The sending side should recieve the response, open the file in binary mode (default on *nix; use binmode for windows), and then split the file into chunks of the agreed size (probably somewhere around 1000 bytes, leaving room for a validation header if you need it.).
  5. Each chunk should be sent separately; the next chunk should be sent after the reciever sends an "ok".
  6. The recieving side should re-assemble the file by stripping the headers and then writing it to a temp file. After recieving the entire file, it should move the temp file to its properly location and rename it.

Actual implementation details may vary, but you'd need to do something like this. I'd be much easier to use an existing protocol like FTP and an aforementioned module to compliment it.


:^) # Fear the wrath of the hyper smiley!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://197915]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-04-16 18:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found