Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

help for accept sys call

by Anonymous Monk
on Mar 05, 2005 at 12:38 UTC ( [id://436885]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

while(($reachedTimeout == 0) && ($Testindex < $noOfTests) && ($client += $GLOBAL_SERVER->accept())) { $in = <$client>;
using this code i try to get value in $in scalar. but many a times it returns some junk value. i do not know how is thsi happening.

Replies are listed 'Best First'.
Re: help for accept sys call
by davido (Cardinal) on Mar 05, 2005 at 15:56 UTC

    I'm having a hard time guessing what module accept() is a method of. Can you tell us so that we (I) can read the module's POD to see if an answer lies within?

    Also, what exactly do you mean by "some junk value"? That may be valuable information (and then again it may not, but until we see we won't know).

    Ready to try to find an answer...


    Dave

      I'm having a hard time guessing what module accept() is a method of. Can you tell us so that we (I) can read the module's POD to see if an answer lies within?
      perldoc -tf accept says (since it is a core operator):
      accept NEWSOCKET,GENERICSOCKET Accepts an incoming socket connect, just as the accept(2) +system call does. Returns the packed address if it succeeded, fal +se otherwise. See the example in "Sockets: Client/Server Communication" in perlipc. On systems that support a close-on-exec flag on files, the + flag will be set for the newly opened file descriptor, as deter +mined by the value of $^F. See "$^F" in perlvar.

      -- Randal L. Schwartz, Perl hacker
      Be sure to read my standard disclaimer if this is a reply.

        Thanks merlyn. :) It looked to me like an object method so I went diving into CPAN to figure out what module it might be.

        So now I have a question which isn't evident in perlfunc: What's going on with the usage in this OP's example? It looks to me like accept() is being used as an object method, which means that the first argument passed to accept() will be the object's reference, rather than NEWSOCKET. I've probably missed something else elementary, but a little clarification would set my mind at ease. :)

        Or is it possible that accept() is a method of some module, and not the core builtin?


        Dave

Re: help for accept sys call
by fokat (Deacon) on Mar 05, 2005 at 16:02 UTC
    (...) but many a times it returns some junk value. i do not know how is thsi happening.

    And what is $GLOBAL_SERVER? What is that "junk value" that is being returned? I will assume that ->accept() is calling the perl's builtin accept().

    If this supposition is correct, this snippet from perldoc -f accept might be enlightening:

    accept NEWSOCKET,GENERICSOCKET
          Accepts an incoming socket connect, just as the accept(2) sys-
          tem call does. Returns the packed address if it succeeded,
          false otherwise. See the example in "Sockets: Client/Server
          Communication" in perlipc.

    This "junk" could be the packed address of the client connecting to your socket. On the other hand, this might be IO::Socket->accept() instead of the builtin, so the earlier snippet would not apply directly...

    Note that accept() can be interrupted by signals, so it may be returning undef. In any case, please provide a bit more of detail, so that we can properly help you.

    Best regards

    -lem, but some call me fokat

      actually this returns string like
      test0001 passed
      but many times it also returns
      testebug failed .
      actually it shouls return status of test just like in first case. when i submit tests like test0001 after they are complated it returns its status along with test name but i am wondering when i am not submitting any test case like testebug why it is returning it.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (8)
As of 2024-04-18 14:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found