in reply to accept() on non-blocking socket still hangs

even though I made socket FH non-blocking

Where have you done this? I would have expected something like fcntl(FH, F_SETFL, $flags | O_NONBLOCK) but don't see anything like that. I'd try it out to see if it fixes your problem, but your code doesn't run on my machine ("Bad symbol for filehandle" on the accept($sock[$numsocks], FH) call.)

Replies are listed 'Best First'.
Re: Re: accept() on non-blocking socket still hangs
by Zip (Initiate) on Mar 17, 2001 at 07:57 UTC
    I just tried using  fcntl(FH, F_SETFL, $flags | O_NONBLOCK);, but it gave me this error:

    Your vendor has not defined Fcntl macro F_SETFL, used at server.pl line 20.

    What do I do now? :-/
      You need to use the Fcntl module. Luckily, it's part of the core distribution. You might also look in perlopentut, under 'Opening Non-File Files'.

      Update: Move along, nothing to see here. My error is abundantly clear (He must have used Fcntl, which is why the fcntl() call didn't throw the error.) Oops.

        chromatic, the error:

        Your vendor has not defined Fcntl macro F_SETFL, used at server.pl line 20.

        means that Zip did use Fcntl and that it reported that F_SETFL was not defined on the platform in question (at the time that the module was compiled).

                - tye (but my friends call me "Tye")
Re^2: accept() on non-blocking socket still hangs
by jyothi vajja (Initiate) on Nov 23, 2004 at 08:48 UTC
    You can set it to nonblocking using setsockopt(). But i have one moer doubt please. How accept() will hang if it is blocking ? whether it is bblocking or non blocking it has to process the connect request fully and if there is any RST from clietnt also. Is it related with different clients connect requests?because in this case only this nonblock eill be usefull to process other client request instaed of hanging with one client Please clear my doubt. Thanks and Regards Jyothi Vajja