如何实现在Android上的HTTP服务器 [英] How to implement an HTTP server on android
问题描述
我已经通过WIFI设置在同一局域网两款Android应用程序:
I've two android applications on same LAN provided by WIFI :
- 在应用程序(一)打开一个监听套接字端口8033
- 应用(二)使用HttpClient的访问(A)在端口8033
如何使之成为可能(A)可进行POST和GET的(B)?
请求
怎么进入(B)使用(A)的URL看起来像?
How to make it possible that (A) may do POST and GET requests on (B)?
What the URL used by (A) to access (B) looks like ?
感谢所有。
推荐答案
您可能会混淆两个不同层次的网络通信。
4级:两个插槽之间的TCP连接
间侧的逻辑管道(可以是单(双进程?)或两个不同的计算机上)
只有连接处理的数据都在这个水平手柄
7级:浏览器/应用服务器所使用的特定通信的语言来交换高级数据(文件,图像,音频..),并在这一水平处理
你的问题是即将开启一个监听套接字(4级)和一个客户端,告知其与HTTP协议(7级)。
所以你错过填补了国内空白插槽听方处理HTTP协议
可能是Java的Web服务器实现可能会帮助你。
You may confuse two different level of networking communication.
Level 4 : TCP connection between two sockets.
A logical pipe between to side (may be single(two process?) or two different computers)
only connection handling data are handle at this level
Level 7 : Browser / Application Server used particular communication "language" to exchange high level data (file , images, audio ..) and is handled at this level.
Your question is about to open a Listening Socket (level 4) and a client that talk with it with a HTTP protocol (level 7).
So you're miss to fill the gap socket listening side to handle HTTP protocol
May be a java web server implementation may help you.
-
在Java EE方式有HTTP服务器:微小的Java Web服务器 @的 http://tjws.sourceforge.net/ ,可以帮助你为你在找什么
a Java EE way to have HTTP server : "Tiny Java Web Server" @ http://tjws.sourceforge.net/ that may help you for what you're looking for
的阿帕奇办法有HTTP服务器的http://www.androiddevblog.net/android/a-bare-minimum-web-server-for-android-platform
看到
http://en.wikipedia.org/wiki/OSI_model#Layer_3:_Network_Layer
拥有这些通信层的更完整
an "Apache" way to have HTTP server http://www.androiddevblog.net/android/a-bare-minimum-web-server-for-android-platform
see
http://en.wikipedia.org/wiki/OSI_model#Layer_3:_Network_Layer
to have more complete view of these Communication Layer
这篇关于如何实现在Android上的HTTP服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!