BTW, what i get before I do teh "shared" thing is that the reports are
getting back, but not on time, in a seemingly random way as I type
characters on teh client side. I tried adding $SOCK->flush; to
sockout() but that doesn't help.

On 10/27/06, Daniel McBrearty <[EMAIL PROTECTED]> wrote:
> Hi
>
> I have an app I'm writing which runs as a background process,
> communicating with the main app over a localhost socket. It's a little
> server.
>
> the basic code looks like this:
>
> <SNIP>
> my $SOCK;
>
> my $sock = new IO::Socket::INET ....
>
> $SOCK = $sock.accept();
>
> while (1) {
>   my $line;
>
>   while ($line = <$SOCK>) {
>     # process line ...
>
>     sockout($response);
>   }
> }
>
> sub sockout{ print $SOCK shift.$CRLF; }
> <?SNIP>
>
> and this works fine.
>
> Now I want to run a thread inside this app that sends back info
> regularly. It needs to run in a seperate thread, and be startable and
> stoppable, which I have working. I don't care if the responses from
> the main thread and the reporter thread lines are mixed up ... ie
>
> OK
> report : 27
> OK
> Ok
> report : 89
>
>
> is fine.
>
> So I try these changes ... :
>
> my $SOCK :shared;
> .
> .
> .
> sub sockout {
>   my $r = shift;
>   lock ($SOCK);
>   print $SOCK $r.$CRLF;
> }
>
> and just call sockout from the reporter thread. But I get this error:
> "Invalid value for shared scalar"  when it hits $SOCK =
> $sock.accept(); ... and I can see why in the threads::shared docs
>
> so my q is : how do I share access to the socket between threads in
> the simplest way?
>
> thanks perlers!
>
> --
> Daniel McBrearty
> email : danielmcbrearty at gmail.com
> www.engoi.com : the multi - language vocab trainer
> BTW : 0873928131
>


-- 
Daniel McBrearty
email : danielmcbrearty at gmail.com
www.engoi.com : the multi - language vocab trainer
BTW : 0873928131
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to