in reply to Threaded Sockets, access from outside thread?

I can't print anything to the master server socket via sendServer
What socket? $controlSocket is undefined (Can't use an undefined value as a symbol refer). Try to share.
  • Comment on Re: Threaded Sockets, access from outside thread?

Replies are listed 'Best First'.
Re^2: Threaded Sockets, access from outside thread?
by ecuguru (Monk) on Jun 16, 2006 at 05:40 UTC
    $controlSocket is declared globally uptop, and then is configured in the sub commandPath to initiate the socket to the master server.
    Even though I declared it globally, I can't access it from outside the thread.
    Unless you're seeing something else and I'm misinterpreting what you're saying?

      I think he means
      my $controlSocket;
      should be
      my $controlSocket :shared;
      Variables aren't automatically shared.

        Thanks
        I tried that before, but ended up getting:
        thread failed to start: Invalid value for shared scalar at server_clie +nt_thread.pl line 41. thread failed to start: Invalid value for shared scalar at server_clie +nt_thread.pl line 59. for lines: $controlSocket = IO::Socket::INET->new("localhost:1024") or pr +int "Can`t open feed\n"; and $server = IO::Socket::INET->new( Proto => 'tcp',
        If the shared call is right, should I be declaring the socket calls differently?