MFC 中的蓝牙
我正在尝试将蓝牙服务器编写为 MFC 应用程序,虽然我让它作为带有阻塞套接字的控制台应用程序工作,但我无法使用 CAsyncSocket 让它工作。 它返回的错误是 10035 - WSAEWOULDBLOCK 一旦我调用 Accept()
我就可以复制代码,但它太长了,所以我只概述一下总体思路: - 创建、绑定常规套接字并开始监听,就像在 Microsoft SDK 示例应用程序中一样 - 将此套接字附加到 CAsyncSocket - 调用Accept()(这是错误发生的地方)
有什么想法如何让蓝牙与CAsyncSocket一起工作吗?
I'm trying to write a Bluetooth server as a MFC app and while I got it working as a console app with blocking sockets, I can't get it working using CAsyncSocket.
The error it returns is 10035 - WSAEWOULDBLOCK as soon as I call Accept()
I could copy the code, but it's way too long, so I'll just outline the general idea:
- create, bind regular socket and start listening just like in the Microsoft SDK example app
- attach this socket to CAsyncSocket
- call Accept() (this is where the error occurs)
Any ideas how to get Bluetooth working with CAsyncSocket?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
CAsyncSocket的OnAccept成员函数在可以Accept时被调用。子类 CAsyncSocket 并处理 OnAccept 通知。
CAsyncSocket's OnAccept member function is called when you can Accept. Subclass CAsyncSocket and handle the OnAccept notification.
谢谢,我已经纠正了这一点,但是 OnAccept、OnConnect() 等从未执行过,即使直接调用时也没有执行。事实证明,我必须删除编译器和链接器使用的所有临时文件才能发现我使用的是全局简写函数 log(),它与 math.h 中定义的 log() 发生冲突,并且导致一些奇怪的行为。
有关更多信息,请参阅此线程 http://www.codeguru.com/forum/showthread .php?t=339413
更新:现在您可以在 Brm 蓝牙遥控器上下载完成的应用程序和整个源代码主页!
Thanks, I've corrected that, but OnAccept, OnConnect(), etc. were never executed, not even when called directly. It turned out that I had to delete all the temporary files the compiler and linker use to find out that I was using global shorthand function log() which clashed with log() defined in math.h and which caused some weird behavior.
See this thread for more datails http://www.codeguru.com/forum/showthread.php?t=339413
UPDATE: now you can download the finished app and the whole source code on Brm Bluetooth Remote Control homepage!