I need to connect to a TCP server that uses a protocol called fix (financial
information exchange)
Basically the server receives a text string and answers with a text string
also.
The protocol is pretty simple, and it consists in a series of fields
separated by the char alt+1:☺
$message1="8=FIX.4.0.c☺35=A☺9998=D3765☺9997=4443734☺9996=Bara☺";
It is supposed that I will receive an answer from the server that should be:
$message2="8=FIX.4.0.c☺35=A☺52=10/24/2006 10:30:34 AM☺100=PFG☺";
The server talks TCP, as stated by its owner, and it can be accessed at some
ip and some port.
Well, trying to keep it simple, I wrote this script:
use IO::Socket;
$message1="8=FIX.4.0.c☺35=A☺9998=D3765☺9997=4443734☺9996=Bara☺";
$host="11.35.72.194";
$port="1000";
$handle = IO::Socket::INET->new(Proto => "tcp",
PeerAddr => $host,
PeerPort => $port,
# Reuse => "1",
# Listen => "1",
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";
#up to here, the connection worked fine
if($handle){print "ok, it worked!\n";}
#now I write to the socket:
print $handle $message1;
#now I hope to get the answer
$response=<$handle>;
print $response;
#I should have received the same as $message2. Instead, the run hangs and
nothing happen.
Am I doing the right thing to enter in conversation with an TCP server?
Thank you to anyone that can shed some litght. Maybe I should ask something
more to the server owner? What?
Alejandro
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs