No subject

Benjamin Franks benjamin at
Wed Dec 5 09:54:43 CST 2001

I'm using the LWP::UserAgent for a small tcp/ip client/server application I've written.  All that the client does is query a small http server I've written on a different host.  It works.  

However, after a couple thousand connections, I notice the client(s) stop getting info from the server.  They continue to run, but when I look at netstat, I see a high number of clients stuck in the FIN_WAIT_2 state (the second part of the disconnection sequence).  They don't seem to come out of this state.  Concurrent with this problem, I notice error messages from the client something like:
  Can't locate LWP/Authen/ in @INC ...
  Can't locate LWP/Authen/ in @INC ...
But these errors only come up after the application has run for a long time, and seem to also coincide with a lot of waiting processes which haven't disconnected.

Here is the rough-code for the small, custom web server.  It's a single-process, no-threads, doesn't fork, etc..  I'm running FreeBSD 4.3 on both client and server system.  Has anyone had problems like this before?  I've been looking through Stephen's Unix Network Programming, and there are small references to things like shutting down sockets rather than closing them.  Or that on BSD, there is a roughly 11 minute timeout for FIN_WAIT_2 states.  Is there a sysctl variable I can set to decrease this?  Am I running out of descriptors when too many get locked in FIN_WAIT_2, and is that why I can't successfully request?  

Any info or ideas would be appreciated.  Thank you,

my $socket=IO::Socket::INET->new ( LocalPort   => $port,
                                   Listen      => SOMAXCONN,
                                   Reuse       => 1 ) or die "oops: $!";

while (#some continuation conditions#) {
	eval {
      		local $SIG{HUP}=sub{$done++; die;};
   	local $/ = "\015\012\015\012";
	if ($c) {
		#do some stuff and print back to $c#
		close $c;



 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at       PROBLEMS: owner-spug-list at
      Subscriptions; Email to majordomo at  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
     Seattle Perl Users Group (SPUG) Home Page:

More information about the spug-list mailing list