IOS 5 中的 TCP 客户端,之前字符串的部分内容仍然是 NSStream
我感到非常沮丧,我的 mac 上运行着一个 tcp 服务器,其中连接了几个设备。我想让我的 iphone 连接到它,这样我就可以从我的 iphone 直接运行一些命令到我的 mac @ home。
我的 iphone 的 tcp 客户端工作得很好,除了一个错误,它似乎没有清除我发送的每个字符串的输出流。这是我遇到问题的一个例子,
- 我在 iPhone 客户端上输入“启动浏览器”,然后点击发送
- 消息在我的 mac 上弹出,到目前为止一切正常,
- 我想从我的 iPhone 发送另一个命令并输入“ B”并点击发送
- iPhone 上的输出将是“Btart my browser”
- 看起来它会将之前的字符串保留在缓存或其他内容中。
有人有什么建议吗?我将不胜感激所有帮助,如果您需要查看我的任何代码,请发布一条消息,我会将其发布。
I am getting pretty frustrated, i have an tcp server running on my mac where i have a couple of devices hooked up to. I wanted to have my iphone connected to it so i can run som commands from my iphone directly to my mac @ home.
The tcp client for my iphone works pretty good except for one fault, it seems like it doesnt clear up the outputstream for each string i send. Here is an example of what i am having problems with
- I type in "Start my browser" on my iphone client and hit send
- The message pops up on my mac, everything ok so far
- I want to send another command from my iphone and type "B" and hit send
- The output on the iphone will then be "Btart my browser"
- It seems as it keeps the previous string in cache or something.
Does anyone have any sugestions? I would appreciate all help, if you need to see any of my code please post an message saying so and i will have it posted.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
没有任何代码我只能猜测,但这看起来像是处理字符串输入的代码中的错误。如果您使用 NSMutableString / NSMutableData 来存储输入,请确保在接受命令后清除该输入。现在看起来您只是覆盖了开头,而没有先实际删除它。
Without any code I can only guess, but this looks like a bug in your code that handles the string input. In case you are using a NSMutableString / NSMutableData to store your input, make sure you clear that input after accepting a command. It now looks like you just overwrite the beginning without actually erasing it first.
问题的根源是我的服务器软件没有清空数据流。当我清空服务器端的流时,它工作得很好。
The source of the problem was that my server software not emptying the datastream. When I emptied the stream on the server side, it worked perfectly.