I suspect, there's some confusion here. Within "threads" connections can be shared without problem. Well, there are issues with synchronization of access (and that can be very complex) but still, the IO::Socket::INET object is directly accessible. The same is true for forked processes if the fork has happened AFTER connection acceptance/creation.

In all other cases, connection information has to be passed from one process to another. I don't know about Windows, but in Unix this is done via IO::Socket::UNIX socket. As already mentioned, this involves passing of file descriptor only (fileno). Basically, when kernel gets request to pass file descriptor to the peer, it creates for the destination process new file descriptor that would point to kernel structures to which old file descriptor was pointing. The peer process just needs to wrap file descriptor into IO::Socket::INET structure using IO::Socket::INET->new_from_fd($fd, 'r').

Of course, simple writing of information into file and then reading it in another process won't do any good. Remember, it is kernel that takes file descriptor number and maps it to real connection data, and such mapping is process specific. So file descriptor 4 in one process has nothing in common with file descriptor 4 in another process. One has to ask kernel to allow for process X to have file descriptor that would point to the same connection data as in the current process.


In reply to Re: Keeping an INET socket inside a shared object by andal
in thread Keeping an INET socket inside a shared object by Superfox il Volpone

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.