----- Original Message -----
From: Peter Eisengrein <[EMAIL PROTECTED]>
To: Perl-Win32-Users Mailing List (E-mail)
<[EMAIL PROTECTED]>
Sent: Friday, April 27, 2001 10:46 PM
Subject: RE: newbie IO::Socket question


> >Your server would run through that code each time it received a message,
> >then sit and wait for another message ( if you've set it up that way).
It's
> >up to the client to send the relevant message so that the server can send
> >the appropriate response.
>
> It is meant to be very simple... the client only needs to login (this
works)
> and then sends a "get" (this works). At that point the server opens the
> appropriate file and prints the contents to the client (this works).
> However, a completely separate app on the server is collecting real time
> data into the file at the same time. So, this server needs to also send
any
> updates, which is why it is stuck in the for loop. Problem is, once the
> server enters the for loop the client has no way of closing the connection
> other than closing the server script. I am guessing maybe I can somehow
use
> %SIG but I am not really familiar with how to use it (samples
appreciated!)
>
> The process flow basically needs to be:
> CLIENT SERVER
> <-----------listen
> connect---->accept
> login------>accept|deny
> <-----------send OK if accepted
> send get--->open file
> receive<----stream data (for loop) and listen for quit
> quit------->close connection
>
>
> Thanks for the help.

Hi,

Can't the following be adapted to do this:

$flag = 1;
while ($flag == 1) {
if the server decides it has something to send {
open the file;
run through the for loop that sends the data stream;
close the file;
}
else {
$flag = 0;
}
}

I thought from your first post that it was up to the client as to whether
the server had to send additional stuff - now this post leads me to believe
that it is the server that makes this decision ( though I don't know how it
reaches that decision ).
I'm also thinking that whenever the server sends something it will be the
contents of that same file.
And I'm also thinking that perhaps I've still missed the point :-)

Anyway the above "script" would have the server continually run through the
file, sending data to the client, until the server decides it will no longer
do that - at which point $flag is set to 0, the 'while' loop is exited and
the connection is closed.

I question the need to send the data as a series of streams, but afaik that
will be done without any break in the connection, so it should not be a
problem. If it turns out to be a problem couldn't you simply save all the
data in one constant and send it in a single message when the server has
finished doing it's stuff ?

Cheers,
Rob



_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

Reply via email to