简体   繁体   English

服务器端编程

[英]server-side programming

I'm looking to program something for an Android machine. 我正在为Android机器编程。 Basically I want the phone to communicate with a server, sending it TCP/UDP packets, and I want the server to reply to the phone an answer depending on the packet received. 基本上我希望手机与服务器通信,发送TCP / UDP数据包,我希望服务器根据收到的数据包回复电话。

I did it while ago, with 2 PC's it wasn't really a problem. 我之前做过,有2台PC,这不是一个真正的问题。 I had my "server side" running on a loop listening to a certain port and then replying. 我让我的“服务器端”在一个循环上运行,听取某个端口然后回复。

My question is how should I write this code if I don't want to have a PC running as a server? 我的问题是,如果我不想将PC作为服务器运行,我应该如何编写此代码? Any recommendations on a good free-host-server on the web, and what kind of language I should use..? 关于网上一个好的免费主机服务器的任何建议,以及我应该使用什么样的语言..?

As you can see I'm a bit lost, and need some tips/guides or anything that will help me get started. 你可以看到我有点迷失,需要一些提示/指南或任何有助于我开始的东西。

Thanks a lot 非常感谢

Since you want to go from a server on the web to an android device there are a large number of choices. 由于您希望从Web上的服务器转到Android设备,因此有大量选择。 Just as a starting point I'd look into Google App Engine as your server (Free for light traffic) and Android development. 作为一个起点,我将把Google App Engine视为您的服务器(免费用于轻量级流量)和Android开发。 If you search for those two keywords (GoogleAppEngine & Android) I bet you find many tutorials that will get you started. 如果您搜索这两个关键字(GoogleAppEngine和Android),我打赌您会找到许多可以帮助您入门的教程。

PS: Your first paragraph describes every single web application ever created--in fact it would make a reasonable definition of what a "Server Application" is--so I'd say it's somewhat general but I hope I got the idea of what you were after and gave you a push in the right direction. PS:你的第一段描述了有史以来创建的每一个Web应用程序 - 实际上它会对“服务器应用程序”的定义做出合理的定义 - 所以我会说它有些普遍但我希望我能够了解你的内容是在追求并向你推进正确的方向。

Without better understanding of the problem space in play, he says: 他没有更好地理解游戏中的问题空间,他说:

Honestly, you're better off just writing a web service the phone can contact via HTTP. 老实说,你最好只写一个手机可以通过HTTP联系的网络服务。 All of the APIs are already there in both Android and whatever server side technology you want to use (Java, Python, Ruby, knock yourself out). 所有的API都已经存在于Android和您想要使用的任何服务器端技术中(Java,Python,Ruby,自己敲门)。

Writing a bespoke socket connector is pretty archaic... 1990 called, they want their proprietary socket protocol back... 编写一个定制的套接字连接器是相当古老的... 1990年,他们想要他们的专有套接字协议回来...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM