Adriano wrote:
Hello,
I have a situation where I need to send a query in the form of "byte array"
to a remote server and then receive the response back also in the form of
"byte array". To be more precise, I cannot figure out how to form the
packet
in VB.NET and send it through sockets, you can see the packet structure
at http://www.epay.tj/img/MML-Packets.jpg
Any help on that would be greatly appreciated.
thanks in advance,
Adriano
I would create a MemoryStream and use a BinaryWriter to write the data
to it. Use the ToArray method to get the contents of the MemoryStream as
a byte array.
Some code to get you started:
MemoryStream m = new MemoryStream();
using (BinaryWriter writer = new BinaryWriter(m, Encoding.Default)) {
writer.Write("`sc`");
writer.Write(60 + login.Length);
writer.Write("1.00");
writer.Write(terminalId);
writer.Write(serviceName);
writer.Write(id);
writer.Write("DLGLGN");
writer.Write(0);
writer.Write(id2);
writer.Write("TXBEG ");
writer.Write(0);
writer.Write(login);
writer.Write(checksum);
}
byte[] data = m.ToArray();
--
Göran Andersson
_____
http://www.guffa.com