>> 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?
>
>Try just reading a max size buffer and taking what you get:
>
>my $buffer;
>my $bytes = sysread ($handle, $buffer, 1024);
>if (not defined $bytes or $bytes < 0) {
># err
>} elsif ($bytes == 0) {
># EOF
>}
># we now have $bytes worth of data in $buffer.
># process the data and do a select before the next read
># unless blocking is OK

Bill, I was using your solution successfully to read several messages sent
by the server, but when trying to work some request,
which had a longer answer, your buffer only gets:

!APID3765PFGPFG!START!^C^,D3765,10/30/2006,1,0,ESZ6,1383.25,D3765-904495,|
^C^,D3765,10/31/2006,1,0,ESZ6,1381,D3765-907899,|

which is the first part of the answer. The complete answer should be:

!APID3765PFGPFG!START!^C^,D3765,10/30/2006,1,0,ESZ6,1383.25,D3765-904495,|
^C^,D3765,10/31/2006,1,0,ESZ6,1381,D3765-907899,|
!APID3765PFGPFG^R^,911655,0,0,ESZ6 ,138650,LIMIT,DAY,0 ,0,0,01-Nov-06 N@
7:39:48 AM ,F ,1386.5 ,GLOBE,0,0,1 ,BUY ,1 |
^R^,911690,0,0,ESZ6 ,138725,LIMIT,DAY,0 ,0,0,01-Nov-06 N@ 7:50:36 AM ,F
,1387.25 ,GLOBE,0,0,2 ,BUY ,2 |
^R^,911703,0,0,ESZ6 ,138600,LIMIT,60,0 ,0,0,01-Nov-06 N@ 7:57:10 AM ,F
,1386. ,GLOBE,0,0,2 ,BUY ,2 |
!APID3765PFGPFG^P^,904495,D3765,11-01-2006,1,0,ESZ6,1383.25,1381.7500,-75|
^P^,907899,D3765,11-01-2006,1,0,ESZ6,1381.,1381.7500,37.5|
^P^,911655,D3765,11-01-2006,1,0,ESZ6,1386.5,1381.7500,-237.5|
^P^,911690,D3765,11-01-2006,2,0,ESZ6,1387.25,1381.7500,-550|
^P^,911703,D3765,11-01-2006,2,0,ESZ6,1386.,1381.7500,-425|
!APID3765PFGPFG^F^,911655,1 ,1386.50 ,FILL720651851,0, ,|
^F^,911655,1 ,1386.50 ,FILL720651851 ,|
^F^,911690,2 ,1387.25 ,FILL720686890,0, ,|
^F^,911690,2 ,1387.25 ,FILL720686890 ,|
^F^,911703,2 ,1386.00 ,FILL7206991213,0, ,|
^F^,911703,2 ,1386.00 ,FILL7206991213 ,|

How could I modify your routine, which is the following:

my $buffer;
my $bytes = sysread ($handle, $buffer, 1024);
if (not defined $bytes or $bytes < 0) {
#err
print "error!!!";
} elsif ($bytes == 0) {
# EOF
}
return $buffer;

In order to get the full answer and avoid the program to hang.

Thank you again,

Alejandro


PS: I don't know what it means,what do you mean by "unless blocking is OK?".


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

Reply via email to