I m astartner in python (2.6/2.7), who have been made in the deep end to establish a web services to an existing python app.
I ve got a UDP server up and running which works just great but I m asking for help in making it slightly more bullet proof.
这里是我撰写的基数,通常的标准锅炉板:
import sys
import socket
from threading import Thread
def handleInput():
sock = socket.socket( socket.AF_INET, socket.SOCK_DGRAM )
sock.bind( ("127.0.0.1",5005) )
# socket always binded?
while True:
data, addr = sock.recvfrom(512)
# is data usable?
t=Thread(target=handleInput)
t.daemon=True
t.start()
# can thread die?
首先,我的理解是,从某种意义上讲,这份摘要总是可以提供,但不必听,因此不存在失败,你必须重新联系。 这是否正确?
第二,从数据中回收的问题。 如果数据:?
第三,也是最后一点。 read子炸弹能否爆炸? 如果是怎样才能重新启动?
任何其他方面都会受到欢迎。
(说明:我不能使用外部图书馆,例如前线图书馆等)