Best communication strategy between Android client and .Net C# server [closed]

非 Y 不嫁゛ 提交于 2019-12-21 05:09:44

问题


I was exploring various methods for implementing communication between a home made TCP/IP server and a Android client application.

Some ideas: - TCP/IP Server bases on JSON - Service with WCF library - Some sort of REST server

What is the beast strategy and libraries to approach this problem?


回答1:


For simple messaging, and status checks, any HTTP based solution would be a much better choice than coming up with your own TCP/IP protocol.

HTTP traffic is significantly less likely to be firewalled, so you will avoid a lot of accessibility and configuration problems.

Whether or not you should use REST, depends on the nature of your application. REST makes a lot of sense for CRUD applications, but make much less sense for other types of applications.




回答2:


Why TCP/IP instead of basic HTTP?

Android has solid support for interacting with the cloud via HTTP - Check out the HttpClient object, and the "SampleSyncAdapter" sample project in the sample code folder of your SDK installation for a handy example.

Choosing a format (XML, JSON, etc) is really up to you, but if you're interested in making your application RESTful (or determining if that's appropriate), a good place to start would be the Google IO talk on Android REST Client Applications.




回答3:


This answer comes a bit late but you can also consider to use Eneter Messaging Framework. It is the lightweight cross-platform framework allowing to implement the communication with messages. For the communication with .NET you can use TCP or HTTP protocols.
Example of the communication between Android and .NET is here.
Technical info you can find here.
I hope it will help somebody.




回答4:


You may use json based objects, serialize and deserialize them and post them to aspx page. A good articles is available here http://www.youritbuddy.com/blog/post/2016/11/14/json-communication-between-android-and-asp-net-c



来源:https://stackoverflow.com/questions/4072805/best-communication-strategy-between-android-client-and-net-c-sharp-server

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!