Thanks Rob. I think that my problem is just the terminator character, but on
the string sent by the server, and not mine.

I am using this script now:
use IO::Socket;

    # create a tcp connection to the specified host and port
    $handle = IO::Socket::INET->new(Proto     => "tcp",
                                    PeerAddr  => $host,
                                    PeerPort  => $port,
                                    Type     => SOCK_STREAM)
           or die "can't connect to port $port on $host: $!";


    $handle->autoflush(1);              # so output gets there right away
    print STDERR "[Connected to $host:$port]\n";

#Now I begin to talk to the server:
#this is the
$message="8=FIX.4.0.C9=3935=A9998=D37659997=44437349996=Bara10=180";
#and I send it in the face of the server:
print $handle "$message\n";

#Now I read the response, and here is the problem:

#1. This failed miserably. The program hanged indefinitely
# @answerfromserver=<$handle>;
#$answerfromserver=join "",@answerfromserver;
#print $anserfromserver;

#2. This failed also miserably. The program hanged indefinitely
#my $byte;
#    while (sysread($handle, $byte, 1) == 1) {
#        print $byte;
#    }

#3. This worked, after several tries when I gess correctly the right length
of the answer to be 55 bytes!!!
for($i=0;$i<57;$i++){
sysread($handle,$byte,1);
print $byte;
}


The output was:
8=FIX.4.0.C35=A52=10/26/2006 8:16:10 AM100=PFG10=999
What is simply correct, but if I put 58 instead of 57, the program hangs
indefinitely.
Obviously I don't know the lengh fo the message beforehand.

Anyone has any idea why this happens and how to avoid it?

Thanks

Alejandro


----- Original Message ----- 
From: "Sisyphus" <[EMAIL PROTECTED]>
To: "Alejandro Santillan" <[EMAIL PROTECTED]>;
<activeperl@listserv.ActiveState.com>
Cc: "perl-win32-user" <perl-win32-users@listserv.ActiveState.com>
Sent: Thursday, October 26, 2006 1:24 AM
Subject: Re: help with sockets



----- Original Message ----- 
From: "Alejandro Santillan" <[EMAIL PROTECTED]>
.
.
>
> use IO::Socket;
>
> $message1="8=FIX.4.0.c☺35=A☺9998=D3765☺9997=4443734☺9996=Bara☺";

#Try instead:
$message1="8=FIX.4.0.c☺35=A☺9998=D3765☺9997=4443734☺9996=Bara☺\n";

I don't know if that will fix the problem, but it's worth a try.

Cheers,
Rob


_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to