Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Thanks for the feedback. You must be experiencing some Windows wackyness. Here is some of the logic behind the forking. The parent is not *really* closing the client connection as far as the client is concerned. In a normal Unix operation, the fork will create duplicate file descriptors for all open files (includeing sockets). The child has access to the listen socket and the client socket, but also the parent has access to both sockets. The parent and child have independant file descriptors. So if the parent closes its file descriptor, the child still has it open and the client will still remain connected. Both parent and child have to disconnect from the client before the socket is closed. After the fork the parent and child both have valid sockets connecting to the client. Since the parent doesnt not need its end of the client socket it closes it's piece. But the child's copy of the connection is still open since it has not closed its own copy. Similarly the child does not need the listen socket anymore so it closes it's copy of the listen socket, this does not close the parent's listen socket ... so the server keeps listening. Only when the child closes the client socket does the socket actually close.

Now that was Unix-land. The rumors I have heard are that Windows-land implemented fork using threads, instead of spawning new processes ... so there could be problems with file handles not being duped with the copies being sent to the child. The only thing that I can think of that a sleep 3 would help would be in the unlikely event that in the windows fork implementation the new thread start running right away leaving the 'parent' thread to continue on it's merry way, while the 'child' thread attempts to dup the parents open filehandles in order to mimic the Unix fork. If the 'child' thread does not have time to dup the file handles before the 'parent' thread closes them then you would get the behavior that you describe. I would consider that to be a bug in the windows implementation of Perl then. Perhaps it would fix things if you upgraded your perl to the latest from ActiveState? Just a thought. Other than that I cant think of a thing that would cause what you describe.

If there is anyone wise in the way of windows-perl, I am interested to hear if there is a firm answer to this problem.
-perlmonkey

In reply to Re: Re: Re: Re: RE(4): MP3 server with IO::Socket by perlmonkey
in thread MP3 server with IO::Socket by perlmonkey

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, 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, 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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    [ELISHEVA]: Text::CSV_XS already can handle boms - see its detect_bom flag
    [ELISHEVA]: but it seems that the DBD::CSV layer on top of it doesn't
    [afoken]: Also: All other attributes that start with csv_ and are not described above will be passed to Text::CSV_XS (without the csv_ prefix).
    [Discipulus]: what about a good 'ol SOPW?
    [erix]: Giro d'Italia won by Dumoulin (peccato Nibali)
    [ELISHEVA]: csv_detect_bom doesn't work either
    [erix]: (SCNR)
    [ELISHEVA]: I may have to resort to SOPW - but was hoping that this would be something simple
    [erix]: I'd just remove the BOM, it is pretty simple
    [ELISHEVA]: Simple yes. and I did consider that. but this isn't one off . An important data source that I don't control is generating bom prefixed utf8 files and I'd rather not have to be munging files every few months.

    How do I use this? | Other CB clients
    Other Users?
    Others musing on the Monastery: (7)
    As of 2017-05-28 20:31 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?