You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by kh...@up.elctech.com on 2001/03/19 06:13:12 UTC

Hanging on IO::Socket call

Hi,

I am running into a problem where an embperl page with the code below
hangs during the while loop reading data from a remote socket. This
function works fine as a standard perl script called cgi under mod_perl.
Has anyone seen this behavior or know of a workaround or fix?

Using:
Embperl     v1.3.1
mod_perl    v1.25
IO::Socket  v1.7
Apache      v1.3.17

Thanks in advance,
Kent

use IO::Socket;

sub MakeRequest {
    my ($msg) = @_;
    my $socket;
    my $data;
    $socket = IO::Socket::INET->new( PeerAddr => "x.x.x.x",
                 PeerPort => "yyyy",
                 Proto    => "tcp",
                 Type     => SOCK_STREAM )
        or die "Couldn't connect : $@\n";
    $msg = $XML_HEAD . $msg;
    print $socket $msg;
    $msg = "";
    while ( ! ( ($data = <$socket>) =~ "</EOF>" ) ) {
        $msg .= $data;
    }
    $msg .= $data;
    close( $socket );
    return $msg;
}


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: Hanging on IO::Socket call

Posted by Gerald Richter <ri...@ecos.de>.
>
> Thank you for your prompt response. I've tried the fix that you suggest
> and also looked through the documentation and neither have helped. Perhaps
> you might have another idea why the calls are
> hanging?
>

If you say it works under mod_perl, there is no reason why it should not
work under Embperl. The only differences is escaping.

Did put the [- $optRawInput = 1 -] in a separte Block before your actual
code ?

Gerald



> Thanks again,
> Kent
>
>
>
> On Mon, 19 Mar 2001, Gerald Richter wrote:
>
> > You need to set optRawInput, see the FAQs about escaping and unescaping,
> > e.g.
> >
> > [- $optRawInput = 1 -]
> >
> >
> >
> > Gerald
> >
> > -------------------------------------------------------------
> > Gerald Richter    ecos electronic communication services gmbh
> > Internetconnect * Webserver/-design/-datenbanken * Consulting
> >
> > Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
> > E-Mail:     richter@ecos.de         Voice:    +49 6133 925131
> > WWW:        http://www.ecos.de      Fax:      +49 6133 925152
> > -------------------------------------------------------------
> >
> > ----- Original Message -----
> > From: <kh...@up.elctech.com>
> > To: <em...@perl.apache.org>
> > Sent: Monday, March 19, 2001 6:13 AM
> > Subject: Hanging on IO::Socket call
> >
> >
> > > Hi,
> > >
> > > I am running into a problem where an embperl page with the code below
> > > hangs during the while loop reading data from a remote socket. This
> > > function works fine as a standard perl script called cgi under
mod_perl.
> > > Has anyone seen this behavior or know of a workaround or fix?
> > >
> > > Using:
> > > Embperl     v1.3.1
> > > mod_perl    v1.25
> > > IO::Socket  v1.7
> > > Apache      v1.3.17
> > >
> > > Thanks in advance,
> > > Kent
> > >
> > > use IO::Socket;
> > >
> > > sub MakeRequest {
> > >     my ($msg) = @_;
> > >     my $socket;
> > >     my $data;
> > >     $socket = IO::Socket::INET->new( PeerAddr => "x.x.x.x",
> > >                  PeerPort => "yyyy",
> > >                  Proto    => "tcp",
> > >                  Type     => SOCK_STREAM )
> > >         or die "Couldn't connect : $@\n";
> > >     $msg = $XML_HEAD . $msg;
> > >     print $socket $msg;
> > >     $msg = "";
> > >     while ( ! ( ($data = <$socket>) =~ "</EOF>" ) ) {
> > >         $msg .= $data;
> > >     }
> > >     $msg .= $data;
> > >     close( $socket );
> > >     return $msg;
> > > }
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> > > For additional commands, e-mail: embperl-help@perl.apache.org
> > >
> > >
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> > For additional commands, e-mail: embperl-help@perl.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> For additional commands, e-mail: embperl-help@perl.apache.org
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: Hanging on IO::Socket call

Posted by kh...@up.elctech.com.
Gerald,

Thank you for your prompt response. I've tried the fix that you suggest
and also looked through the documentation and neither have helped. Perhaps
you might have another idea why the calls are
hanging?

Thanks again,
Kent



On Mon, 19 Mar 2001, Gerald Richter wrote:

> You need to set optRawInput, see the FAQs about escaping and unescaping,
> e.g.
>
> [- $optRawInput = 1 -]
>
>
>
> Gerald
>
> -------------------------------------------------------------
> Gerald Richter    ecos electronic communication services gmbh
> Internetconnect * Webserver/-design/-datenbanken * Consulting
>
> Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
> E-Mail:     richter@ecos.de         Voice:    +49 6133 925131
> WWW:        http://www.ecos.de      Fax:      +49 6133 925152
> -------------------------------------------------------------
>
> ----- Original Message -----
> From: <kh...@up.elctech.com>
> To: <em...@perl.apache.org>
> Sent: Monday, March 19, 2001 6:13 AM
> Subject: Hanging on IO::Socket call
>
>
> > Hi,
> >
> > I am running into a problem where an embperl page with the code below
> > hangs during the while loop reading data from a remote socket. This
> > function works fine as a standard perl script called cgi under mod_perl.
> > Has anyone seen this behavior or know of a workaround or fix?
> >
> > Using:
> > Embperl     v1.3.1
> > mod_perl    v1.25
> > IO::Socket  v1.7
> > Apache      v1.3.17
> >
> > Thanks in advance,
> > Kent
> >
> > use IO::Socket;
> >
> > sub MakeRequest {
> >     my ($msg) = @_;
> >     my $socket;
> >     my $data;
> >     $socket = IO::Socket::INET->new( PeerAddr => "x.x.x.x",
> >                  PeerPort => "yyyy",
> >                  Proto    => "tcp",
> >                  Type     => SOCK_STREAM )
> >         or die "Couldn't connect : $@\n";
> >     $msg = $XML_HEAD . $msg;
> >     print $socket $msg;
> >     $msg = "";
> >     while ( ! ( ($data = <$socket>) =~ "</EOF>" ) ) {
> >         $msg .= $data;
> >     }
> >     $msg .= $data;
> >     close( $socket );
> >     return $msg;
> > }
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> > For additional commands, e-mail: embperl-help@perl.apache.org
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> For additional commands, e-mail: embperl-help@perl.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: Hanging on IO::Socket call

Posted by Gerald Richter <ri...@ecos.de>.
You need to set optRawInput, see the FAQs about escaping and unescaping,
e.g.

[- $optRawInput = 1 -]



Gerald

-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de         Voice:    +49 6133 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------

----- Original Message -----
From: <kh...@up.elctech.com>
To: <em...@perl.apache.org>
Sent: Monday, March 19, 2001 6:13 AM
Subject: Hanging on IO::Socket call


> Hi,
>
> I am running into a problem where an embperl page with the code below
> hangs during the while loop reading data from a remote socket. This
> function works fine as a standard perl script called cgi under mod_perl.
> Has anyone seen this behavior or know of a workaround or fix?
>
> Using:
> Embperl     v1.3.1
> mod_perl    v1.25
> IO::Socket  v1.7
> Apache      v1.3.17
>
> Thanks in advance,
> Kent
>
> use IO::Socket;
>
> sub MakeRequest {
>     my ($msg) = @_;
>     my $socket;
>     my $data;
>     $socket = IO::Socket::INET->new( PeerAddr => "x.x.x.x",
>                  PeerPort => "yyyy",
>                  Proto    => "tcp",
>                  Type     => SOCK_STREAM )
>         or die "Couldn't connect : $@\n";
>     $msg = $XML_HEAD . $msg;
>     print $socket $msg;
>     $msg = "";
>     while ( ! ( ($data = <$socket>) =~ "</EOF>" ) ) {
>         $msg .= $data;
>     }
>     $msg .= $data;
>     close( $socket );
>     return $msg;
> }
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> For additional commands, e-mail: embperl-help@perl.apache.org
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org