언어 설정

Menu
Sites
Language
App running a simple http server

Is it possible to run a simple http server within the application, which responds to the requests within the local network?

I am looking for something like nanohttpd, SimpleWebServer which are  compactable with android.

Please help. Thanks in advance.

Responses

1 댓글
Iqbal Hossain

Hi~
I think you can use Socket Programming for your purposes. 

Sockets are the basis for all connections over the internet. They are the end pieces which both a client and server terminate a connection with.

When you make an HTTP request over the internet, it typically opens a socket connection to the server, and sends a request header, followed by an optional request body. This is just a stream of bytes, and it’s up the the receiving socket to know when the message is completely received. For HTTP this is handled by specifying the Length of the payload. The client can then just receive until it has Length bytes, then take those bytes and parse them as a request. To reply, it would then send back a response using the same semantics.

Ref: https://medium.com/@ivanderbyl/why-you-don-t-need-socket-io-6848f1c871cd#.9rqkoeugs