Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Answer: How do I send a file through a Socket Connection ?

( #251898=categorized answer: print w/ replies, xml ) Need Help??

Q&A > network programming > How do I send a file through a Socket Connection ? contributed by SiMac

Sometimes (mainly when you're passing a file from one a process running under one user id to another process under a different user id) it makes sense to pass the filehandle and not the file. To do this, you'd want to use Socket::PassAccessRights as follows:

Socket::PassAccessRights::sendfd(fileno(SOCKET), fileno(FILE_DESCRIPTOR));

On the other end you'd want to receive like:

$file_descriptor = Socket::PassAccessRights::recvfd(fileno(SOCKET));

This unlikely to work on any system not purporting POSIX compliance. According to the author of the module, the socket passing code in Linux and FreeBSD is buggy, so use this module only when necessary.

Comment on Answer: How do I send a file through a Socket Connection ?
Select or Download Code
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (14)
As of 2015-07-29 18:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (267 votes), past polls