Hello everyone!
I have such a code in my Java application that I would like to convert to Perl. The problem is I don't know how to send a byte array through a socket in Perl.
The Java code looks like this:
byte[] request = new byte[4];
request[0] = 17;
request[1] = 0;
request[2] = 0;
request[3] = 0;
Socket socket = new Socket(hostname, port);
os = new DataOutputStream(socket.getOutputStream());
os.write(request);
Generally speaking my Perl code works, it can connect to the server socket and transmit data but cannot send in a proper format as the Java application does.
Here are the core segments:
$socket = IO::Socket::INET->new(PeerPort=>$port, Proto=>'tcp', PeerAddr=>$host) or die $!;
$request = pack("i", 17, 0, 0, 0);
$socket->send($request);
I just cannot figure out how to pass the array in binary format so it would be compatible with my protocol.
Any ideas or directions on how to solve this problem are VERY welcome.
Regards,
Railer
I have such a code in my Java application that I would like to convert to Perl. The problem is I don't know how to send a byte array through a socket in Perl.
The Java code looks like this:
byte[] request = new byte[4];
request[0] = 17;
request[1] = 0;
request[2] = 0;
request[3] = 0;
Socket socket = new Socket(hostname, port);
os = new DataOutputStream(socket.getOutputStream());
os.write(request);
Generally speaking my Perl code works, it can connect to the server socket and transmit data but cannot send in a proper format as the Java application does.
Here are the core segments:
$socket = IO::Socket::INET->new(PeerPort=>$port, Proto=>'tcp', PeerAddr=>$host) or die $!;
$request = pack("i", 17, 0, 0, 0);
$socket->send($request);
I just cannot figure out how to pass the array in binary format so it would be compatible with my protocol.
Any ideas or directions on how to solve this problem are VERY welcome.
Regards,
Railer