嵌入式Web服務器軟件構成與工作原理(一)

嵌入式Web服務器軟件構成與工作原理(一)

 

嵌入式Web服務器的工作原理

1、服務器軟件(BOA)始終在HTTP端口守候客戶端的連接請求,當客戶端向服務器發起一個連接請求後,客戶端和服務器之間經過“三步握手”建立起連接。

2、在接收到客戶端的HTTP請求消息後,服務器對消息進行解析,包括:讀取請求URL、映射到對應的物理文件、區分客戶端請求的資源是靜態頁面還是CGI應用程序等。

3、如果客戶請求的是靜態文件,那麼服務器讀取相應的磁盤文件,並將其作爲HTTP響應消息中的實體返回給客戶端,如果客戶端請求的是CGI應用程序,那麼服務器將創建相應的CGI應用程序進程,並將各種所需信息(客戶端請求信息、服務器端相關信息等)按CGI規範傳遞給CGI應用程序進程,此後由CGI應用程序接管控制。

 

CGI應用程序的工作原理

1、CGI應用程序讀取從Web服務器傳遞來的各種信息,並對客戶端的請求進行解釋和處理,如:使用SQL語句來檢索或者更新數據庫。

2、CGI應用程序將處理結果按照CGI規範返回給Web服務器,Web服務器會對CGI應用程序的處理結果進行解析,並在此基礎上生成HTTP響應信息返回給客戶端。

 


 

嵌入式Web服務器軟件構成與工作原理圖

 

 

嵌入式Web服務器軟件構成

編號

軟件名稱

類型

說明

01

BOA

Web服務

它是一個運行在類UNIX系統中的小型Web服務器開源軟件。它的基本功能包括:和客戶端建立連接,接收客戶提交的HTTP請求消息,將HTTP響應消息返回給客戶,關閉連接等。

02

CGI

Web應用程序

CGI(Common Gateway Interface公共網關接口)規範給出了Web服務器和CGI應用程序進程之間傳遞信息的標準,是嵌入式Web服務器中實現客戶與服務器動態交互的主要手段;網關應用程序也叫CGI應用程序,遵循CGI規範和Web服務器進行交互,並能通過在網關應用程序中內嵌的SQL語句實施對數據庫的訪問操作。

03

SQLite

嵌入式數據庫

SQLite是一個嵌入式數據庫管理系統,與CGI應用程序處於同一個服務器平臺。

 

 

Embedded Web Server Software Composition And Working Principle, Part One

 

 

EmbeddedWebServerWorking Principle
1, the server software (BOA)is always waiting forclient in theHTTP port for connection requests, when aclient  initiates aconnection requestto the server, the client and server establish connection via"three-stephandshake".
2, after receiving the client's HTTPmessage requests, the serverparses the messages, including:reading therequestURL,mapping tothe correspondingphysical file, the differentiatingthe client requestsresources between
a staticpage and CGIapplications, etc.
3, if the client requests is a staticfile, then the server reads thecorrespondingdisk file,and asan entityin the HTTPresponse messageback to the client, if the clientrequestis the CGIapplication,then theserver will create the appropriateCGIapplication process, and all the necessaryinformation (client requestsinformation, the serverinformation, etc)according to CGI specification will bepassed to theCGIapplication process, thentake over controlto the CGIapplication.

 

CGI Application Working Principle
1, CGI application reads varieties of information from the Web server, interprets and processesclient requests, for example: using SQL statements to retrieve or update the database.
2, CGI application will return the results in accordance with the CGI specification back to the Web server, Web server CGI application will parse the results and generate HTTP responses based on this information back to the client.

 

Schematic Diagram

 

 

Embedded Web Server Software Composition

Num

Softeware Name

Type

Explanation

01

BOA

Web Sever

It is a small running inpan-UNIX system Web server open source software. Its basic functions include: establish a connectionwith the client,receive HTTP request message,return the HTTP requests messageto the client, and close the connection.

02

CGI

Web Application

CGI(Common Gateway Interface) Specificationgives astandard of the Webserver andCGItheapplicationpassing information, is a primary means ofdynamic interactionbetween client andserver in embedded Web server,gateway applications, also known as CGI applications, follow the CGI specification and Interact withWeb server, and through CGI applicationsSQL statements implement database access operations.

03

SQLite

Database

SQLite is an embedded database management system, with CGI application on the same server platform.

 

發佈了25 篇原創文章 · 獲贊 26 · 訪問量 14萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章