我正在try 将int转换为byte,但找不到适合我的示例
我需要将字节中的int转换为tcp ip中发送的字节
final server = await ServerSocket.bind(ip,port);
try{
server.listen((Socket socket) {
int a = 10; // line feed
int b = 36; // $
int c = 122; // z
const sec = Duration(seconds:1);
Timer.periodic(sec,(Timer t) {
socket.wite('data : $a,$b,$c');
});
} on SocketExeption catch(ex) {
print(ex.message);
}
我收到了
|d|a|t|a| |:|1|0|,|3|6|,|1|2|2|
我如何接受
|d|a|t|a| |:|LF|,|$|,|z| or |d|a|t|a| |:|0x0A|,|$|,|z|
我和plc一起工作,他喜欢绝对索引中的字节
有可能吗?
如果使用
int a = 0;
for(;;){
socket.write(String.fromCharCode(a));
a++;
if(a>=256)a=0;
}
通过tcp ip接收
byte0 =00.01....4F........7D.7E.7F.C2.C2....C2.C2..C2.C2.C3.C3.C3..C3.C3.00.01...
byte1 =00.00....00........00.00.00.80.81....84.85..BE.BF.80.81.82..BE.BF.00.00...
In any case i can use strings but for some protocols it's a huge of data, minimun moltiply x4 如果使用 3 char 和 one separator
我try 在windows应用程序上使用RTC和Flutter
对于上一个项目,我创建了
javaServer<-low side code bit/byte->plc
和
flutter<-json->javaServer
我觉得很难看
工作感谢麻风
try {
client.listen((Socket socket) {
debugPrint('New TCP client ${socket.address.address}:${socket.port} connected.');
List<int> bytes = List.empty(growable: true);
for (var i = 0; i < 255; i++) {
bytes.add(i);
}
Timer.periodic(const Duration(seconds: 1), (Timer t) {
for (var i = 0; i < 255; i++) {
socket.add([bytes[i]]);
}
});
});
} on SocketException catch (ex) {
debugPrint(ex.message);
Timer.periodic(Duration(seconds: 1), (Timer t) {
startServer();
});
}