Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Socket Handle not sending data ?

by targetsmart (Curate)
on Jul 09, 2009 at 10:42 UTC ( #778536=note: print w/ replies, xml ) Need Help??


in reply to Socket Handle not sending data ?

push that created socket handle(no need to push the port number too) into an array, and iterate through that array to send data when you want to.
that text file idea won't work.
I am not sure about, whether one can persistently store a socket handle into a file and use it on the next launch of the same script. This could happen rarely and I think you have not encountered a relevant situation like this.


Vivek
-- 'I' am not the body, 'I' am the 'soul', which has no beginning or no end, no attachment or no aversion, nothing to attain or lose.


Comment on Re: Socket Handle not sending data ?
Re^2: Socket Handle not sending data ?
by evilkamikaze (Initiate) on Jul 09, 2009 at 14:31 UTC

        For starters, please use <c>...</c> instead of <pre>...</pre>.

        It looks like your object got stringified

        $ perl -e' > sub method {} > my $o = bless({}); > $o->method(); # Ok > $o = "$o"; > $o->method(); > ' Can't locate object method "method" via package "main=HASH(0x814ec28)" + (perhaps you forgot to load "main=HASH(0x814ec28)"?) at -e line 6.

        Tracing back I see you read a string from a file and expect it to magically become a socket handle. That's not gonna happen.

        In fact, the handle gets closed at the end of PortConn as the last reference to it ($rethandle) goes out of scope.

        The idea is fundamentally flawed. A handle is a token that represents a resource the OS has handed your process. The token is useless to any other process. If you want to store something, you need to store the connection details so you can re-establish the connection.

          Hi, Could you please point some good design options? Also, will it work if I try to make it without threads using non-blocking socket call? so if I try to connect to a port and it is not up then instead of blocking I just skip to next port without any delay. Is this something that makes more sense than previous approach? Thanks

    Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Node Status?
    node history
    Node Type: note [id://778536]
    help
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others examining the Monastery: (8)
    As of 2014-07-11 05:13 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      When choosing user names for websites, I prefer to use:








      Results (219 votes), past polls