I am sure this is a basic one …
I would like to act as a TCPClient , I am able to connect, and to send data
but I cant figure out how to “get” the incoming data from the server
tcpTest.vl (18.9 KB)
I am sure this is a basic one …
I would like to act as a TCPClient , I am able to connect, and to send data
but I cant figure out how to “get” the incoming data from the server
assuming you are trying to receive strings? have you seen “HowTo Send and receive strings” in the help browser?
Hey Joreg, yes, but I want to get raw bytes
I was trying this aproach
I can see the Iobox bang every time I send data, but nothing on the output
then you just take what’s coming out of the Tokenizer. if you’re wondering about a spread of spread coming out of the Tokenizer, that is because there may be multiple tokens received at once. so you have to decide how to deal with that. often a LastOrDefault will be fine…
ok, but the data that I am trying to get its unknown in framesize and header/tail
I want to strip “raw” tcp packages basically, be able to count how many packages I got, and the size of them. If some of them match a header I need to parse them in one way or another
I need to do something like that I did in JS
const net = require('net');
if (process.argv.length !== 3) {
console.error('Usage: node connecttoserver.js <ip> <port>');
process.exit(1);
}
const ip = process.argv[2];
const port = 30500
const client = new net.Socket();
client.connect(port, ip, () => {
console.log('Connected to server');
});
client.on('data', data => {
ParseData(data)
});
client.on('close', () => {
console.log('Connection closed');
});
client.on('error', err => {
console.error('Socket error:', err.message);
});
// Handle Ctrl+C to gracefully close the connection
process.on('SIGINT', () => {
client.end();
process.exit();
});
let framecounter = 0;
function ParseData(data){
framecounter++;
const hexData = data.toString('hex');
console.log(data.length,hexData)
console.log()
}
and where my output is
112 aa7068001edd0b2c0221244750524f542c2c562a30380d0a24505341542c4850522c2c2c2c2c2a35430d0affffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff007a
26 aa1a0100017d0c2c000000000000001004000000000000000049
112 aa70680065b20c2c02422447504747412c2c2c2c2c2c302c2c2c2c4d2c2c4d2c2c2a36360d0a2447505654472c2c542c2c4d2c2c4e2c2c4b2c4e2a32430d0a2447504845562c2c2a34430d0affffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00d6
250 aa706800c8670d2c0221244750524f542c2c562a30380d0a24505341542c4850522c2c2c2c2c2a35430d0affffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0010aa1a0100e5c40d2c000000000000001004000000000000000015aa7068005c0b0e2c02642447504747412c2c2c2c2c2c302c2c2c2c4d2c2c4d2c2c2a36360d0a2447505654472c2c542c2c4d2c2c4e2c2c4b2c4e2a32430d0a2447505a44412c2c2c2c2c2c2a34380d0a244750524d432c2c562c2c2c2c2c2c2c2c2c2c4e2c552a32410d0a244750006e
so you’re saying the data you receive doesn’t follow a parsable protocol?
then even remove the Tokenizer, which is only there to help you tokenize following a known protocol. if you really only want to have the raw bytes, then just don’t use a Tokenizer?!
but beware: TCP is a stream protocol, not a package protocol, ie the individual chunks you receive is not exactly how they were sent (hence why typically you use a Tokenizer to make sure to receive whole packs as they were sent by the sender).
got it, I was trying to fix something that was never meant to be there…
thank you!