in reply to Re: Client-Server Programme hangs...
in thread Client-Server Programme hangs...

The Sample output I gave was my initial script the one I posted was to reproduce the same issue with a smaller code, as the other code ran to about 4000 or more lines with some dbi connections and queries against the database.
Why I am creating a new socket with every command entered by the user is also because I could not get the script to work with just one connection...as I explained above the main script does the following
1. accept a users command
2. parse the users command to see if the syntax is correct
3. connect to a local oracle database and execute the relevant sql with regards to the command entered by the user
4. go to a server that should have similar data based on an already defined hostname, oracle sid, username and password and check whether the same data is there
5. report back to the user on the local host the results
6. User now gets the prompt back and can enter new commands if wanted

I have tried to put $socket->close ; in a varied number of places especially in the function that creates client connections but I am sure this did not fix the issue. I will test this out again and post my findings.
Thanks for the tip.

Replies are listed 'Best First'.
Re^3: Client-Server Programme hangs...
by Errto (Vicar) on Dec 31, 2004 at 17:02 UTC
    One other thing. Make sure you put $socket->autoflush() immediately after you create the socket at the client side, and $session->autoflush() immediately after you accept the connection on the server side. In your current code the proper place to do a $socket->close() would be after the return from host_to_user.
      Hello Errto,
      Thanks for your last suggestions I have implemented all that you said but it really did not help, to resolve the issue. It's still hanging...

      sub host_to_user { + my $nread ; my $inp ; $/ = CRLF ; while (<$socket>) { chomp; + my @data = split/-/, $_ ; print $_ , "\n"; print "The first value is $data[1]\n"; if ($data[1] eq 'THISISTHEEND') { $socket->close ; print " I have executed the close\n"; return 0 ; } } # + $socket->close ; #<- position 2 ###print " I have executed the close\n"; # return ; }

      The output is still the same the following is the output of the above code.

      $ ./client Testing> Hello I have received your message[server]-THISISTHEEND The first value is THISISTHEEND I have executed the close Testing> So what ^C$ $

      I even tried to put the $socket->close () in what I mentioned as position 2, but that was worse and the execution never got to the close section so I took it out.
        Then my only suggestion is to put some print statements in your server code, run it in a terminal, and make sure that the loop reading from $session actually exits when it should.