คือผมจะเขียนโปรแกรมเป็น client ติดต่อกับ server แต่ client จะต้อง run รอการติดต่อกับ server ตลอดเวลาที่โปรแกรมทำงานอยู่นะครับ
ไม่ทราบว่าผมจะต้องใช้ library อะไรหรือครับ หรือว่าให้ต้องเขียนเป็นเทรดหรือครับ หรือว่าต้องเขียนให้โปรแกรมรันเองทุกๆ 1 นาทีเพื่อตรวจสอบอะครับ
By khao_lek on
Tag:
Hiring! บริษัทที่น่าสนใจ
Carmen Software
Hotel Financial Solutions
Next Innovation (Thailand) Co., Ltd.
We are web design with consulting & engineering services driven the future stronger and flexibility.
KKP Dime
KKP Dime บริษัทในเครือเกียรตินาคินภัทร
Kiatnakin Phatra Financial Group
Financial Service
Fastwork Technologies
Fastwork.co เว็บไซต์ที่รวบรวม ฟรีแลนซ์ มืออาชีพจากหลากหลายสายงานไว้ในที่เดียวกัน
Thoughtworks Thailand
Thoughtworks เป็นบริษัทที่ปรึกษาด้านเทคโนโยลีระดับโลกที่คว้า Great Place to Work 3 ปีซ้อน
Iron Software
Iron Software is an American company providing a suite of .NET libraries by engineer for engineers.
CLEVERSE
Cleverse is a Venture Builder. Our team builds several tech companies.
Nipa Cloud
#1 OpenStack cloud provider in Thailand with our own data center and software platform.
Bangmod Enterprise
The leader in Cloud Server and Hosting in Thailand.
CIMB THAI Bank
MOVING FORWARD WITH YOU - CIMB is the leading ASEAN Bank
Bangkok Bank
Bangkok Bank is one of Southeast Asia's largest regional banks, a market leader in business banking
MuvMi (Urban Mobility Tech Co.,Ltd.)
Shape the future of urban mobility towards affordable, clean, and safe solutions
T.N. Digital Solution Co., Ltd.
TNDS has been involving in every first move of banking’s major digital transformation.
KBTG - KASIKORN Business-Technology Group
KBTG - "The Technology Company for Digital Business Innovation"
Siam Commercial Bank Public Company Limited
"Let's start a brighter career future together"
Icon Framework co.,Ltd.
Global Standard Platform for Real Estate แพลตฟอร์มสำหรับธุรกิจอสังหาริมทรัพย์ครบวงจร มาตรฐานระดับโลก
REFINITIV
The Financial and Risk business of Thomson Reuters is now Refinitiv
H LAB
Re-engineering healthcare systems through intelligent platforms and system design.
The Gang Technology Co., Ltd.
We're a Digital Agency that helps our customers transform their business into digital with ease.
LTMH
LTMH มุ่งเน้นการพัฒนาผลิตภัณฑ์ที่สามารถช่วยพันธมิตรของเราให้บรรลุเป้าหมาย
Seven Peaks
We Drive Digital Transformation
Wisesight (Thailand) Co., Ltd.
The Best Choice For Handling Social Media · High Expertise in Social Data · Most Advanced and Secure
MOLOG Tech
We are Modern Logistic Platform, Specialize in WMS, OMS and TMS.
Data Wow Co.,Ltd
We enable our clients to realize increased productivity by solving their most complex issues by Data
LINE Company Thailand
LINE, the world's hottest mobile messaging platform, offers free text and voice messaging + Call
LINE MAN Wongnai
Join our journey to becoming No.1 food platform in Thailand
code
khao_lek Mon, 27/10/2008 - 08:53
code ที่ผมเขียนขณะนี้อะครับ คือเมื่อผมติดต่อกับ server ได้เรียบร้อยแล้ว ผมต้องการให้โปรแกรมที่ผมเขียนรันไปดึงข้อมูลที่ได้จาก
server ตลอดเวลาที่โปรแกรมทำงานอยู่ครับ ในcode ผมลองใช้ทั้ง timer และ thread แต่ก็โปรแกรมล่มตลอดเลยครับ
def OnConnetServer(self, event):
self.tcpsoc = socket(AF_INET, SOCK_STREAM)
try:
self.tcpsoc.connect(self.ADS)
self.SetStatusText("ติดต่อกับ sever ได้แล้ว ".decode("utf-8"))
self.isConnet = True
ss = threading.Timer(30, self.OnRequestServer())
ss.start()
while 1:
self.OnRequestServer()
except:
self.isConnet = False
self.SetStatusText("ไม่สามารถติดต่อกับ sever ได้ ".decode("utf-8"))
def OnRequestServer(self):
#self.t1 = wx.Timer(self)
#self.t1.Start(1000)
data = self.tcpsoc.recv(1024)
if not data:
print "no data from server "
else:
self.temText += "Server : " + str(data) + '\n'
self.txtMsgList.SetValue(self.temText)
#self.t1.Stop()
#del self.t1
มีสองแบบใ
meledictas Mon, 27/10/2008 - 01:00
มีสองแบบให้เลือก
1. ใช้ SocketServer ซึ่งเป็นการ implement แบบ thread มีให้เลือกทั้ง TCP (ThreadingTCPServer) และ UDP (ThreadingUDPServer)
2. ใช้ Asynchronous socket handler (asyncore, asynchat ) ตัวนี้ใช้เทคนิค os call ที่ชื่อ select อันนี้มันกว่า ประสิทธิภาพดีกว่าและโค๊ดสะอาดกว่าเพราะเป็น single process
ขอบคุณครั
khao_lek Mon, 27/10/2008 - 09:03
In reply to มีสองแบบใ by meledictas
ขอบคุณครับ
ใช่ SELECT ตัวนี้หรือเปล่าครับคุณ meledictas ถ้าใช่เดี่ยวไปลองดูก่อนครับ
The select module is a
meledictas Mon, 27/10/2008 - 10:44
The select module is a python module for accessing the select() and poll() system core. You can use it but it is unnecessary, there is a high-level implementation. See http://effbot.org/librarybook/asyncore.htm for more detail. :)
ลองใช้ Twisted
hereblur Mon, 27/10/2008 - 12:18
ลองใช้ Twisted ดูดีกว่าครับ จะได้ไม่ต้องมาปวดหัวกับเรื่องพวกนี้