C# 和 ActiveSync 通信/打开和读取文件
我有一个设备通过支架 USB 连接到主机。现在,我只是想知道是否可以使用 C# 套接字与设备通信(即设备发送数据,主机处理数据然后回复设备)。我怎样才能做到这一点?这样,我必须更改什么IP地址等才能连接,因为我的套接字在无线上工作。如果没有,那么有没有办法连接到设备,打开文件(更具体地说是文本文档)并从设备读取到我的主机应用程序。有什么想法吗?
谢谢! :)
I have a device connected to a host computer through cradle usb. Now, I'm just wondering if I could use C# sockets to communicate with the device (ie device sending data, host computer processing it then replying back to the device). How can I accomplish this? by that, what ip address etc etc.. do I have to change so that it would connect cause I have the sockets working on wireless. If not, then is there a way to connect to the device, open and read a file (a text document to be more specific) from the device to my host application.. any ideas?
Thanks! :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据您的目标设备,当您通过 ActiveSync 连接时,它可能会在两个设备之间建立本地 RNDIS 网络连接。您可以将“ppp_peer”解析为合作伙伴的网络名称,而不是尝试使用硬编码的 IP 地址(IIRC XP 上的 IP 与 Vista 上的不同)。
请注意,这不是完全连接。 TCP 数据包可以通过,但 ICMP 等数据包却不能通过。
当然,这只是为您提供了一个套接字连接,就像您在两台 PC 之间进行连接一样。除非您在另一端有一个应用程序侦听命令,否则它不会允许您执行文件系统操作。如果您想要这种类型的东西,Microsoft 提供了远程 API (RAPI) 接口(此处封装在托管代码中)用于许多基本命令,它可以是 扩展(使用 C) 可以做任何你想做的事情。
Depending on your target device, when you connect via ActiveSync it likely makes a local RNDIS network connection between teh two devices. You can resolve "ppp_peer" as the partner's network name instead of trying to use a hard-coded IP address (IIRC the IP is different on XP than on Vista).
Be aware that it's not a full connection. TCP packets gets passed through, but things like ICMP do not.
Of course, this just gives you a socket connection, just like if you were to connect between two PCs. It's not going to allow you to do file system operations unless you have an app on the other side listening for commands. If you want that type of thing, Microsoft provides the Remote API (RAPI) interface (wrapped in managed code here)for a lot of basic commands, and it can be extended (with C) to do anything you'd like.