通过USB线在C#.net和Android之间传输数据 [英] Transfer the data between C#.net and Android through USB cable

查看:530
本文介绍了通过USB线在C#.net和Android之间传输数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



i想要使用窗口7 OS,.NET 3.5(Visual Studio 2008)和Android,所以我希望在c#.net和android之间进行数据传输应用程序通过usb cable.Actually我不知道如何以及在哪里可以启动该application.please任何身体将给出一些基本的想法..



谢谢

hello guys,

i want use window 7 OS,.NET 3.5(Visual Studio 2008) and Android,so i want data transfer between c#.net and android application via usb cable.Actually i don't how and where can start that application.please any body will give some basic ideas..

thanks

推荐答案

不确定usb有线电视位 - 为什么你不能使用wifi?



写一些代码



a)Windows框上的AC#server / service,用于侦听特定端口上的连接,接受连接,读取数据,解密/发回响应



b)Android设备上的java'客户端' - 与tcp / ip地址和端口组合的连接 - 即来自(a)的c#服务/服务器的地址,写入一些数据,并读取响应



每边(a&b)你可以写本地测试存根



你应该能够ake代码'channel'独立,所以你有一个接口wifi / usb等



'g'
not sure about the usb cable bit - why cant you use wifi ?

Write some code

a) A C# server/service on your windows box that listens for a connection on a particular port, accepts connection, reads the data, intereprets/sends back a response

b) a java 'client' on your Android device - that conenctions to a tcp/ip address & port combination - ie, the address of the c# service/server from (a), that writes some data, and reads the response

on each side (a & b) you can write local test stubs

You should be able to make the code 'channel' independant, so you have an interface to wifi/usb etc

'g'


我想要只连接电缆。我的膝盖没有wifi.so只,但还可以。给出一些基本代码或基本概念。
I want connect only cable. my lap have not wifi.so only , but ok. give some basic code or basic concepts.


如此宽泛!



OSI模型(http://en.wikipedia。 org / wiki / Osi_model)有助于解释网络的基础知识,但是,网络中发生的每一层都很难。

这些图层与您在计算机上键入的内容完全相同(第7层到传输信息的电线(第1层)。



如果你不这样做我不建议你制作一个基于网络的应用程序非常了解网络。







幸运的是,我们不需要对每个方面进行编程OSI模型,.Net Framework有很多类可以帮助你忽略低级细节(参考读取简单信使 - AC#MSN Messenger-like聊天应用程序 [ ^ ])。我确信Android也有,特别是因为你可以使用Java。



如果应用程序要在任何给定时间接收数据,那么你需要有一个在两端打开数据包监听器对象(这将是一个服务器,某处总是向招揽开放)。



您是否需要数据完整性(不丢失信息) )?将数据包编程为TCP(传输控制协议)。



您是否需要完整性并且能够承受丢失传输中的某些数据(如电视信号)?使用UDP(用户数据报协议)。在这种情况下,您需要不断地在循环中编程数据包请求,因为UDP是一种1-solicitation-1-packet-sent方式。





请下次通过分享您对网络的了解来缩小范围。
So broad!

The OSI model (http://en.wikipedia.org/wiki/Osi_model) helps explain the basics of networking, but still, each layer of what goes on in networking can be tough.
The layers go all the way from what you type on your computer (layer 7) to the very wires where information is transmited (layer 1).

I wouldn't recommend you to make a network-based application if you don't know much about networking.



Fortunately, we don't need to program every aspect of the OSI model, the .Net Framework has a lot of classes that help you overlook the low level details (for a reference read Simple Messenger - A C# MSN Messenger-like Chat Application[^]). I'm sure Android has that too, specially since you can use Java.

If the application is to receive data at any given time, then you need to have an open "packet listener" object at both ends (this would be a "server", somewhere always open to solicitations).

Do you need data integrity (no information lost)? Program packets as TCP (Transmission Control Protocol).

Do you not need integrity and can afford to loose some data in transmission (like a TV signal)? Use UDP (User Datagram Protocol). In this case, you need to program packet solicitations in a loop constantly, because UDP is a 1-solicitation-1-packet-sent way to work.


And please, next time narrow things by sharing what you already know about networking.


这篇关于通过USB线在C#.net和Android之间传输数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆