[英]Kryonet - buffer overflow - small object sending
Hiho. 嗨。 Everything was running without problems on localhost.
在localhost上运行的一切都没有问题。 Now the server is set on a professional host.
现在服务器设置在专业主机上。 The error is always the same:
错误总是一样的:
10-04 16:35:29.974 5730-5830/com.drkmns.gameloopballs E/AndroidRuntime: FATAL EXCEPTION: Thread-8160
10-04 16:35:29.974 5730-5830/com.drkmns.gameloopballs E/AndroidRuntime: Process: com.drkmns.gameloopballs, PID: 5730
10-04 16:35:29.974 5730-5830/com.drkmns.gameloopballs E/AndroidRuntime: com.esotericsoftware.kryo.KryoException: Buffer overflow. Available: 0, required: 9
The code is simple: 代码很简单:
String host = ui.inputHost();
try {
client.connect(5000, host, Network.port);
// Server communication after connection can go here, or in Listener#connected().
} catch (IOException ex) {
ex.printStackTrace();
}
name = "MOJANAZWA";
Login login = new Login();
login.name = name;
client.sendTCP(login);
TestPacket test = new TestPacket();
while (true) {
test.msg = "33333333333333";
client.sendTCP(test);
}
The TestPacket class is just with a single string. TestPacket类只有一个字符串。 When I connect via emulator everything works fine.
当我通过模拟器连接一切正常。 When I open it on Samsung Galaxy S4 it throws this exception.
当我在三星Galaxy S4上打开它时会抛出此异常。
Already tried with increasing the buffer in Server's and Client's constructors - didn't work. 已经尝试过增加Server和Client的构造函数中的缓冲区 - 没有用。
Any ideas? 有任何想法吗?
I don't know how is this possible - maybe someone could explain - but sleeping the thread for 1ms worked Oo 我不知道这怎么可能 - 也许有人可以解释 - 但是睡了1毫秒的线程工作Oo
while (true) {
test.msg = "55555444444444444444444444444444444444444444444444444444444444444455";
client.sendTCP(test);
synchronized (client) {
try {
client.wait(1);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.