本文整理汇总了Python中Server.start_server方法的典型用法代码示例。如果您正苦于以下问题:Python Server.start_server方法的具体用法?Python Server.start_server怎么用?Python Server.start_server使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Server
的用法示例。
在下文中一共展示了Server.start_server方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: OnStart
# 需要导入模块: import Server [as 别名]
# 或者: from Server import start_server [as 别名]
def OnStart(self, event=None):
if not self.status:
if not self.me or self.me == '*':
common.showerror(self, tr("Username should not be empty or '*'"))
self.txtName.SetFocus()
return
ip = self.txtIP.GetValue()
if not ip:
common.showerror(self, tr("Host address cannot be empty!"))
self.txtIP.SetFocus()
return
port = int(self.txtPort.GetValue())
self.pref.pairprog_host = ip
self.pref.pairprog_port = port
self.pref.pairprog_username = self.me
self.pref.save()
try:
self.server = Server.start_server(ip, port, self.servercommands)
if self.server:
self.AddUser(self.me, manager=True)
self.change_status('startserver')
self.callplugin('start', self, 'server')
except:
common.warn(tr("Start server error!"))
error.traceback()
else:
self.server.shut_down()
self.server = None
self.change_status('stopserver')
self.callplugin('stop', self, 'server')
示例2: open_connection
# 需要导入模块: import Server [as 别名]
# 或者: from Server import start_server [as 别名]
def open_connection(self):
try:
sockobj = socket.socket(socket.AF_INET, socket.SOCK_STREAM) #Create a socket object
ssl_sock = ssl.wrap_socket(sockobj,
certfile="client_cert.pem",
keyfile="client_cert.pem",
ca_certs="server_cert.pem",
cert_reqs=ssl.CERT_REQUIRED)
ssl_sock.connect(('127.0.0.1', 50007)) #Connect to server
print('SSL Socket created')
print(repr(ssl_sock.getpeername()))
print(ssl_sock.cipher())
print(pprint.pformat(ssl_sock.getpeercert()))
return ssl_sock
except ssl.SSLError:
return None
def makeWindow(myTitle):
root = Tk()
lab1 = Login(root)
root.title(myTitle)
root.geometry("400x200")
root.mainloop()
if __name__ == '__main__':
thread.start_new_thread(makeWindow, ('Client',))
Server.start_server()