Android 客户端 TCP
我在 JAVA 中有一个简单的服务器 TCP 写入,并且有一个连接到服务器的简单 Android 客户端,但是当服务器在 BufferedStream 上写入时,客户端无法读取消息。
如果服务器不在缓冲服务器->客户端上写入,则一切都会完美,但我不明白,因为客户端无法缓冲输入。
客户端有一个textedit和onu按钮,用于在textedit中发送书面消息,但消息不会到达服务器,但是当Android上的应用程序被强制关闭时,消息就会到达服务器。为什么?
I have a simple Server TCP write in JAVA and I have a simple Client Android that connetted to the server, but when the server write on the BufferedStream the client can not read the message.
Everythings works to perfection if the server don't write on the Buffered Server->client but I'm not understanding because the client can not the buffered in input.
The client has a textedit and onu button for the send a written message in the textedit, but the message doesn't arrive to the server, but when the application on Android is forcibly close then the message arrive to the server. WHY?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的最后一句话让我假设你正在使用 BufferedWriter 或类似的东西来发送数据。如果要发送的数据大小低于缓冲区大小,则 BufferedWriter 只是缓冲数据并等待更多数据发送,直到它“认为”“现在我有足够的数据来发送消息”。如果您的消息已准备好发送,您可能需要调用flush()。
Your last sentence lets me assume, that you are using a BufferedWriter or something like that, to send the data. If the size of the data you want to send is below the buffer size, the BufferedWriter simply buffers the data and waits for more data to send until it "thinks" "now I have enough data to send the message". You might want to call a flush(), if your message is ready to be sent.