您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息
三六零分类信息网 > 郴州分类信息网,免费分类信息发布

Python实现telnet服务器的方法

2025/5/9 2:59:07发布6次查看
本文实例讲述了python实现telnet服务器的方法。分享给大家供大家参考。具体实现方法如下:
import threading class mythread(threading.thread): def __init__(self,conn,add): threading.thread.__init__(self) self.inputstr = '' self.connection=conn self.address=add def run(self): ii=0 while true: self.connection.settimeout(50) buf = self.connection.recv(1024) if buf.rfind(\n) > -1 : print **-+self.inputstr self.connection.close() break else: self.inputstr+=buf if ii==0: self.connection.send(buf) ii+=1 continueif __name__ == '__main__': import socket sock = socket.socket(socket.af_inet, socket.sock_stream) sock.bind(('192.168.101.103', 8014)) sock.listen(5) while true: try: connection,address = sock.accept() ithread=mythread(connection,address) ithread.start() except socket.timeout: print 'time out'
希望本文所述对大家的python程序设计有所帮助。
郴州分类信息网,免费分类信息发布

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product