<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>

新聞中心

EEPW首頁(yè) > 嵌入式系統 > 設計應用 > 如何在Dragonbaord 410c上實(shí)現高性能并發(fā)處理TCP服務(wù)器

如何在Dragonbaord 410c上實(shí)現高性能并發(fā)處理TCP服務(wù)器

作者: 時(shí)間:2017-10-11 來(lái)源:網(wǎng)絡(luò ) 收藏

在IOT設計中,通常我們需要構建一個(gè)或者多個(gè)監測和控制網(wǎng)絡(luò ),來(lái)實(shí)現對各種傳感器及設備的數據采集和控制,這樣我們就需要在網(wǎng)絡(luò )中實(shí)現集中管理終端,以對區域的傳感器和設備進(jìn)行集中管理,在云端和底層控制節點(diǎn)之間維護一個(gè)智能化的管理終端,dragonboard 410c憑借其強大的處理性能和網(wǎng)絡(luò )連接能力,可以方便的實(shí)現這一管理終端功能,此時(shí)我們就需要在dragonbaord 410c上設計一個(gè)多任務(wù)的接入服務(wù),讓傳感器和相關(guān)的控制設備接入,為此,本期blog將向大家介紹如何使用gevent高性能的并發(fā)處理庫在draognbaord 410c上來(lái)實(shí)現一個(gè)高性能的TCP服務(wù)器。

本文引用地址:http://dyxdggzs.com/article/201710/365545.htm

gevent是基于協(xié)程的Python網(wǎng)絡(luò )庫。特點(diǎn): 基于libev的快速事件循環(huán)(Linux上epoll,FreeBSD上kqueue)。 基于greenlet的輕量級執行單元。 API的概念和Python標準庫一致(如事件,隊列)。 可以配合socket,ssl模塊使用。 能夠使用標準庫和第三方模塊創(chuàng )建標準的阻塞套接字(gevent.monkey)。

使用gevent來(lái)提高我們的并發(fā)處理性能,首先需要在draongboard 410c上安裝gevent模塊,具體安裝方法如下:

sudo apt-get install libevent-dev

sudo apt-get install python-all-dev

sudo apt-get install python-setuptools

sudo easy_install greenlet

sudo easy_install gevent

完成安裝后,from gevent.server import StreamServer 就可以導入使用gevent來(lái)實(shí)現高效的并發(fā)處理,這里我們以構建一個(gè)簡(jiǎn)答的業(yè)務(wù)邏輯處理服務(wù)為例,具體代碼如下:

from gevent.server import StreamServer

import addressbook_pb2

from testBusinessLogic import testBusinessLogic

BUFSIZE=1024

reportLenMin=10

def handle(socket,address):

while(1):

try:

report=socket.recv(BUFSIZE)

print(report)

if len(report)>reportLenMin:

testLogic=testBusinessLogic(report,“192.168.1.156”)

testLogic.startMainLogicProcess(socket)

else:

print(“recv report error”)

socket.send(“your report is error”)

except:

print(“service error”)

socket.send(“service error”)

if __name__==“__main__”:

testServer = StreamServer((‘192.168.41.156’,5000),handle)

testServer.serve_forever()

到這里我們就完成了整個(gè)測試服務(wù)器的搭建,該服務(wù)器能夠借助于gevent實(shí)現高并發(fā)的處理,并且支持異常處理,可以在dragonbaord 410c上穩定運行,這里testBusinessLogic為測試邏輯處理類(lèi),大家需要實(shí)現的業(yè)務(wù)邏輯可以放到里面實(shí)現,具體不詳細介紹。



關(guān)鍵詞: DragonBoard410c

評論


相關(guān)推薦

技術(shù)專(zhuān)區

關(guān)閉
国产精品自在自线亚洲|国产精品无圣光一区二区|国产日产欧洲无码视频|久久久一本精品99久久K精品66|欧美人与动牲交片免费播放
<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>