SlideShare a Scribd company logo
Can Android be an HTTP Server?
2018.02.06 Tue.
Tsuyoshi Chujo
@ shibuya.apk # 22
About me
Tsuyoshi Chujo
● Freelance engineer of Web services
○ Android, Web server (Servlet, Django, Ruby on Rails), etc.
● Currently, working as an Android developer in a manufacturer
● Social Accounts
○ Qiita: @chooyan-eng
○ GitHub: @chooyan-eng
○ dev.to: @chooyan
○ Twitter: @chooyan_i18n
● CodeYourRuby the device powered by Android
(but NOT a Smart Phone)
Can Android be an HTTP Server?
Ordinal architecture
Client Server
request
response
Can Android be an HTTP Server?
What I would like to discuss today
Client
Server
request
response
YES! Android CAN be an HTTP Server!
● HTTP is based on TCP
● HTTP is a protocol of “How to Control TCP”
○ See OSI or TCP/IP in detail
● All the OS (as far as I know) can use TCP. It’s the function of OS.
● Android OS also can use TCP
● Thus, Android device can be a HTTP server by extending TCP and
implementing the specification on RFC 7230.
How to implement?
● Use java.net.ServerSocket
○ Basic class to accept requests based on TCP/IP protocol
○ InputStream and OutputStream of this class presents TCP Socket.
○ See my GitHub repository if you are interested in usage.
Flow Image
Client Server
open socket
connect accept
GET / HTTP/1.1CRLFUser-Agent: XXXXCRLFCookie:...
parse and calculate the
end of data.
do something...
Then, send back
response.receive data
and parse
send data
HTTP/1.1 200 OKCRLFContent-Type: text/htmlCRLF...
establish connection
Demo
if app does not work… see below :-(
https://www.youtube.com/watch?v=_hZ_UsFKnIU
Open the URL below with your favorite web browser :-)
http://XXX.XXX.XXX.XXX:20000
https://github.com/chooyan-eng/AndroidHttpServerDemo
When to Use? (in my experience)
● Embedded Android (Android on devices for specific operation)
○ Send data DIRECTLY from PC to Android devices via LAN.
○ Send data with TCP connection. (Not using HTTP, but basic idea is the same as discussion here)
end data
and control the device
response
Thank you!

More Related Content

PDF
Situações didáticas
PDF
PPT
Diagnóstico trabalho23
DOCX
Plano de ação 6º ano ferraz
PDF
Tecnicas de Ensino e Dominios de Aprendizagem
PDF
Damas na escola
PPTX
Computação desplugada
DOCX
Relatório de aplicação do jogo matemático
Situações didáticas
Diagnóstico trabalho23
Plano de ação 6º ano ferraz
Tecnicas de Ensino e Dominios de Aprendizagem
Damas na escola
Computação desplugada
Relatório de aplicação do jogo matemático

What's hot (20)

ODT
Plano de curso 7 ano 2017
PPTX
Slides htpc cozinha experimental
PPT
Fundamentos e Metodologia de Ciencias
PDF
Aula01 org.e metodologia-ed.inf-2013-2
PDF
Cartilha inclusao escolar
PPT
ATPC - Adaptação Curricular.ppt
DOCX
Planejamento bimestral mirna
PPT
Projeto Aquarela ApresentaçãO 2007
PDF
Folder - Produção de brinquedos com materiais discartáveis - 3.pdf
PDF
Observação de sala de aula
ODP
Regras da biblioteca
PDF
Cartaz: Dia Mundial de Conscientização do Autismo
PDF
Redação discursiva
PDF
comunicacao-linguagem-fala
PPTX
Alfabetização-Psicogênese da Língua escrita
PPT
Estimulação cognitiva e técnicas de intervenção clínica no TDAH
PPTX
Planos_de_LINGUAGENS 1.pptx
DOC
65677659 aula-teste-de-temperamentos
PPS
Plano de curso 7 ano 2017
Slides htpc cozinha experimental
Fundamentos e Metodologia de Ciencias
Aula01 org.e metodologia-ed.inf-2013-2
Cartilha inclusao escolar
ATPC - Adaptação Curricular.ppt
Planejamento bimestral mirna
Projeto Aquarela ApresentaçãO 2007
Folder - Produção de brinquedos com materiais discartáveis - 3.pdf
Observação de sala de aula
Regras da biblioteca
Cartaz: Dia Mundial de Conscientização do Autismo
Redação discursiva
comunicacao-linguagem-fala
Alfabetização-Psicogênese da Língua escrita
Estimulação cognitiva e técnicas de intervenção clínica no TDAH
Planos_de_LINGUAGENS 1.pptx
65677659 aula-teste-de-temperamentos
Ad

Similar to Can android be an http server (20)

PDF
Introducing chrome apps (ogura)
PDF
Android development
PDF
Burgas Conf 21.06.2014 - Single page application Angularjs and Nodejs
PPTX
Android Study Jam
PDF
Embedded Android Workshop with Nougat
PDF
Embedded Android Workshop with Nougat
PDF
Embedded Android Workshop with Oreo
PDF
You Can Work on the Web Patform! (GOSIM 2023)
PDF
WHAT / WHY / HOW WE’RE ENGINEERING AT SMARTSTUDY (English)
PDF
Journey to become Android Developer - NgodingJeh! @STMIKCIC Cirebon - By: Riz...
PDF
Django on app engine
ODP
Wade.Go Introduction Speech - SFD HCMC 2014
PPTX
Using JavaScript to write Native Mobile Applications
PDF
APIs for mobile
PDF
Embedded Android Workshop
PDF
Web3_Profile.pdf
PDF
RealDay: Angular.js
PDF
SPDY and What to Consider for HTTP/2.0
ODP
Introduction of CMS Technology to the People of Tanay, Rizal Philippines
PDF
Android Made Simple
Introducing chrome apps (ogura)
Android development
Burgas Conf 21.06.2014 - Single page application Angularjs and Nodejs
Android Study Jam
Embedded Android Workshop with Nougat
Embedded Android Workshop with Nougat
Embedded Android Workshop with Oreo
You Can Work on the Web Patform! (GOSIM 2023)
WHAT / WHY / HOW WE’RE ENGINEERING AT SMARTSTUDY (English)
Journey to become Android Developer - NgodingJeh! @STMIKCIC Cirebon - By: Riz...
Django on app engine
Wade.Go Introduction Speech - SFD HCMC 2014
Using JavaScript to write Native Mobile Applications
APIs for mobile
Embedded Android Workshop
Web3_Profile.pdf
RealDay: Angular.js
SPDY and What to Consider for HTTP/2.0
Introduction of CMS Technology to the People of Tanay, Rizal Philippines
Android Made Simple
Ad

Recently uploaded (20)

PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
System and Network Administraation Chapter 3
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
Essential Infomation Tech presentation.pptx
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
AI in Product Development-omnex systems
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Digital Strategies for Manufacturing Companies
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Softaken Excel to vCard Converter Software.pdf
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
System and Network Administraation Chapter 3
Reimagine Home Health with the Power of Agentic AI​
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Odoo Companies in India – Driving Business Transformation.pdf
How Creative Agencies Leverage Project Management Software.pdf
How to Choose the Right IT Partner for Your Business in Malaysia
Essential Infomation Tech presentation.pptx
CHAPTER 2 - PM Management and IT Context
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
How to Migrate SBCGlobal Email to Yahoo Easily
AI in Product Development-omnex systems
Design an Analysis of Algorithms I-SECS-1021-03
Digital Strategies for Manufacturing Companies
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Operating system designcfffgfgggggggvggggggggg
Softaken Excel to vCard Converter Software.pdf

Can android be an http server

  • 1. Can Android be an HTTP Server? 2018.02.06 Tue. Tsuyoshi Chujo @ shibuya.apk # 22
  • 2. About me Tsuyoshi Chujo ● Freelance engineer of Web services ○ Android, Web server (Servlet, Django, Ruby on Rails), etc. ● Currently, working as an Android developer in a manufacturer ● Social Accounts ○ Qiita: @chooyan-eng ○ GitHub: @chooyan-eng ○ dev.to: @chooyan ○ Twitter: @chooyan_i18n ● CodeYourRuby the device powered by Android (but NOT a Smart Phone)
  • 3. Can Android be an HTTP Server? Ordinal architecture Client Server request response
  • 4. Can Android be an HTTP Server? What I would like to discuss today Client Server request response
  • 5. YES! Android CAN be an HTTP Server! ● HTTP is based on TCP ● HTTP is a protocol of “How to Control TCP” ○ See OSI or TCP/IP in detail ● All the OS (as far as I know) can use TCP. It’s the function of OS. ● Android OS also can use TCP ● Thus, Android device can be a HTTP server by extending TCP and implementing the specification on RFC 7230.
  • 6. How to implement? ● Use java.net.ServerSocket ○ Basic class to accept requests based on TCP/IP protocol ○ InputStream and OutputStream of this class presents TCP Socket. ○ See my GitHub repository if you are interested in usage.
  • 7. Flow Image Client Server open socket connect accept GET / HTTP/1.1CRLFUser-Agent: XXXXCRLFCookie:... parse and calculate the end of data. do something... Then, send back response.receive data and parse send data HTTP/1.1 200 OKCRLFContent-Type: text/htmlCRLF... establish connection
  • 8. Demo if app does not work… see below :-( https://www.youtube.com/watch?v=_hZ_UsFKnIU Open the URL below with your favorite web browser :-) http://XXX.XXX.XXX.XXX:20000 https://github.com/chooyan-eng/AndroidHttpServerDemo
  • 9. When to Use? (in my experience) ● Embedded Android (Android on devices for specific operation) ○ Send data DIRECTLY from PC to Android devices via LAN. ○ Send data with TCP connection. (Not using HTTP, but basic idea is the same as discussion here) end data and control the device response