Re: Preventing connections with POE::Component::Server::TCP

2004-03-08 Thread Scott Beck
On Sat, 2004-03-06 at 06:15, Alex J. Avriette wrote:
 On Sat, Mar 06, 2004 at 07:50:13AM -0600, Jay Strauss wrote:
  I think I did not explain my problem correctly.
 
 You did explain it correctly, and Rocco answered correctly.
 
  The idea is the Client::TCP connects to a stock quote server somewhere else
  on the network.  The Server::TCP lets local clients connect to it.  I'd like
  to prevent the local clients from connecting (or shut down the Server::TCP
  completely) when the quote server is unavailable.
 
 In this circumstance, I would think it would be fairly easy to use something
 like Wheel::SocketFactory and just delete the whell when your connection to
 the quote server went away. At that point, you could just set a delay to poll
 for when it comes back, and reinstantiate your whee

See also $wheel-pause_accept(); and $wheel-resume_accept(); in
POE::Wheel::SocketFactory.

Cheers,

Scott

-- 
Scott Beck [EMAIL PROTECTED]
Gossamer Threads



Re: Preventing connections with POE::Component::Server::TCP

2004-03-07 Thread Jay Strauss
I could have sworn that was what I was proposing to do.

Jay
- Original Message -
From: Apocalypse [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Saturday, March 06, 2004 9:43 PM
Subject: Re: Preventing connections with POE::Component::Server::TCP


 Jay Strauss wrote:

 Hi,
 
 I have a POE::Component::Server::TCP.  I'd like to prevent connections
under
 certain circumstances, even though I'm still in the event loop.  Is there
a
 way to do this?  That is I want my program to run, I just don't want to
 allow connections at certain times.
 
 Thanks
 Jay
 
 
 
 I think everyone in here missed one easy way: the shutdown event...

 sub shutdown_server {
 $_[KERNEL]-post( 'tcpserver', 'shutdown' );
 }

 sub restart_server {
 # just call your normal server instantitation code here
 }

 # Of course this won't work but gives you an idea :)
 if ( ! connected_stocks() ) {
 $_[KERNEL]-yield( 'shutdown_server' );
 }

 --
 Apocalypse

 Homepage: http://JiNxEdStAr.0ne.us
 IRC: [EMAIL PROTECTED]
 IRC: [EMAIL PROTECTED]
 CPAN ID: APOCAL







Re: Preventing connections with POE::Component::Server::TCP

2004-03-07 Thread Jay Strauss
I think it's perfectly allowable etiquette to ask if one is heading down a
dead end.

BTW, It works fine, at least for the tests I've run

Jay

- Original Message -
From: Alex J. Avriette [EMAIL PROTECTED]
To: Jay Strauss [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Saturday, March 06, 2004 11:11 AM
Subject: Re: Preventing connections with POE::Component::Server::TCP


 On Sat, Mar 06, 2004 at 08:17:03AM -0600, Jay Strauss wrote:

  Would the way I was thinking present problems?

 Ordinarily, I would think that if you were writing a mailing list
 asking a way to do something, that you were already having problems.

 However, in this case, I am inclined to say that no, it would not
 present any problems, and feel free to ask for more help if you have
 problems with your approach.

 I personally would go the wheel route. But then, that's just me. I
 am still brand-new to POE.

 Alex

 --
 [EMAIL PROTECTED]
 Alex J. Avriette, Unix Systems Gladiator
 Sep 25 12:52:39 buggle /bsd: wsdisplay0 at vga1: removing /dev/radio/*





Re: Preventing connections with POE::Component::Server::TCP

2004-03-06 Thread Rocco Caputo
On Fri, Mar 05, 2004 at 10:49:03PM -0600, Jay Strauss wrote:
 
 I have a POE::Component::Server::TCP.  I'd like to prevent connections under
 certain circumstances, even though I'm still in the event loop.  Is there a
 way to do this?  That is I want my program to run, I just don't want to
 allow connections at certain times.

Not as far as I know.

The problem: accept() returns the remote address, so the connection
must be accepted before you can decide whether the client should
connect.  By that time the client HAS connected, and the best you can
do is hang up on it right away.

You can tweak your firewall if you know your certain circumstances
ahead of time.

-- 
Rocco Caputo - [EMAIL PROTECTED] - http://poe.perl.org/


Re: Preventing connections with POE::Component::Server::TCP

2004-03-06 Thread Alex J. Avriette
On Sat, Mar 06, 2004 at 07:50:13AM -0600, Jay Strauss wrote:
 I think I did not explain my problem correctly.

You did explain it correctly, and Rocco answered correctly.

 The idea is the Client::TCP connects to a stock quote server somewhere else
 on the network.  The Server::TCP lets local clients connect to it.  I'd like
 to prevent the local clients from connecting (or shut down the Server::TCP
 completely) when the quote server is unavailable.

In this circumstance, I would think it would be fairly easy to use something
like Wheel::SocketFactory and just delete the whell when your connection to
the quote server went away. At that point, you could just set a delay to poll
for when it comes back, and reinstantiate your wheels.

alex
--
[EMAIL PROTECTED]
Alex J. Avriette, Microsoft Certified Power User 
Give a homeless hax0r a home today! Run Debian!


Re: Preventing connections with POE::Component::Server::TCP

2004-03-06 Thread Jay Strauss
Would the way I was thinking present problems?

Jay
- Original Message -
From: Alex J. Avriette [EMAIL PROTECTED]
To: Jay Strauss [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Saturday, March 06, 2004 8:15 AM
Subject: Re: Preventing connections with POE::Component::Server::TCP


 On Sat, Mar 06, 2004 at 07:50:13AM -0600, Jay Strauss wrote:
  I think I did not explain my problem correctly.

 You did explain it correctly, and Rocco answered correctly.

  The idea is the Client::TCP connects to a stock quote server somewhere
else
  on the network.  The Server::TCP lets local clients connect to it.  I'd
like
  to prevent the local clients from connecting (or shut down the
Server::TCP
  completely) when the quote server is unavailable.

 In this circumstance, I would think it would be fairly easy to use
something
 like Wheel::SocketFactory and just delete the whell when your connection
to
 the quote server went away. At that point, you could just set a delay to
poll
 for when it comes back, and reinstantiate your wheels.

 alex
 --
 [EMAIL PROTECTED]
 Alex J. Avriette, Microsoft Certified Power User
 Give a homeless hax0r a home today! Run Debian!





Re: Preventing connections with POE::Component::Server::TCP

2004-03-06 Thread Jay Strauss
I think I did not explain my problem correctly.

I have a poe script/server that has both a:

POE::Component::Client::TCP and a POE::Component::Server::TCP

The idea is the Client::TCP connects to a stock quote server somewhere else
on the network.  The Server::TCP lets local clients connect to it.  I'd like
to prevent the local clients from connecting (or shut down the Server::TCP
completely) when the quote server is unavailable.

Though in writing this email I think I figured out how to do it:

when the quote server is down, I send a message to the Server::TCP to shut
down
When the quote server comes up, and I get a connected event, I'll create a
Server::TCP

Thanks
Jay



- Original Message -
From: Rocco Caputo [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Saturday, March 06, 2004 6:56 AM
Subject: Re: Preventing connections with POE::Component::Server::TCP


 On Fri, Mar 05, 2004 at 10:49:03PM -0600, Jay Strauss wrote:
 
  I have a POE::Component::Server::TCP.  I'd like to prevent connections
under
  certain circumstances, even though I'm still in the event loop.  Is
there a
  way to do this?  That is I want my program to run, I just don't want to
  allow connections at certain times.

 Not as far as I know.

 The problem: accept() returns the remote address, so the connection
 must be accepted before you can decide whether the client should
 connect.  By that time the client HAS connected, and the best you can
 do is hang up on it right away.

 You can tweak your firewall if you know your certain circumstances
 ahead of time.

 --
 Rocco Caputo - [EMAIL PROTECTED] - http://poe.perl.org/





Re: Preventing connections with POE::Component::Server::TCP

2004-03-06 Thread Apocalypse
Jay Strauss wrote:

Hi,

I have a POE::Component::Server::TCP.  I'd like to prevent connections under
certain circumstances, even though I'm still in the event loop.  Is there a
way to do this?  That is I want my program to run, I just don't want to
allow connections at certain times.
Thanks
Jay
 

I think everyone in here missed one easy way: the shutdown event...

sub shutdown_server {
   $_[KERNEL]-post( 'tcpserver', 'shutdown' );
}
sub restart_server {
   # just call your normal server instantitation code here
}
# Of course this won't work but gives you an idea :)
if ( ! connected_stocks() ) {
   $_[KERNEL]-yield( 'shutdown_server' );
}
--
Apocalypse
Homepage:   http://JiNxEdStAr.0ne.us
IRC:[EMAIL PROTECTED]
IRC:[EMAIL PROTECTED]
CPAN ID:APOCAL