當前位置: 首頁>>代碼示例>>Python>>正文


Python Function.get_ipv4方法代碼示例

本文整理匯總了Python中Function.get_ipv4方法的典型用法代碼示例。如果您正苦於以下問題:Python Function.get_ipv4方法的具體用法?Python Function.get_ipv4怎麽用?Python Function.get_ipv4使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Function的用法示例。


在下文中一共展示了Function.get_ipv4方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: logout

# 需要導入模塊: import Function [as 別名]
# 或者: from Function import get_ipv4 [as 別名]
def logout(ip):
	print ("\n>>> LOGOUT")
	i = 0
	pk = pack.logout()
	s = func.create_socket_client(func.get_ipv4(ip), const.PORT);
	if s is None:
		func.error("Errore nella chiusura del demone:" + func.get_ipv4(ip))
	else:
		s.sendall(pk)
		s.close()
		i = i + 1
	s = func.create_socket_client(func.get_ipv6(ip), const.PORT);
	if s is None:
		func.error("Errore nella chiusura del demone:" + func.get_ipv6(ip))
	else:
		s.sendall(pk)
		s.close()
		i = i + 1
	if i is 2:
		print ("Logout eseguito con successo.")
開發者ID:tommasoberlose,項目名稱:p2p_gnutella,代碼行數:22,代碼來源:Peer.py

示例2: input

# 需要導入模塊: import Function [as 別名]
# 或者: from Function import get_ipv4 [as 別名]
listPkt = []
listResultQuery = []

####### INIZIO CLIENT #######
nGroup = input("Inserire il numero del gruppo: ")
nElement = input("Inserire il numero dell'elemento del gruppo: ")
host = ("172.030." + func.format_string(nGroup, const.LENGTH_SECTION_IPV4, "0") + 
				"." + func.format_string(nElement, const.LENGTH_SECTION_IPV4, "0") + 
				"|fc00:0000:0000:0000:0000:0000:" + func.format_string(nGroup, const.LENGTH_SECTION_IPV6, "0") + 
				":" + func.format_string(nElement, const.LENGTH_SECTION_IPV6, "0"))

print ("IP:", host)

####### DEMONI

daemonThreadv4 = daemon.Daemon(func.get_ipv4(host), listNeighbor, listPkt, listResultQuery, host)
daemonThreadv6 = daemon.Daemon(func.get_ipv6(host), listNeighbor, listPkt, listResultQuery, host)
daemonThreadv4.setName("DAEMON IPV4")
daemonThreadv6.setName("DAEMON IPV6")
daemonThreadv4.start()	
daemonThreadv6.start()

# Menù di interazione
while True:
	choice = input("\n\nScegli azione:\nupdate\t - Update Neighborhood\ndelete\t - Delete Neighborhood\nview\t - View Neighborhood\nsearch\t - Search File\nquit\t - Quit\n\n")

	if (choice == "update" or choice == "u"):
		updateNeighbor(host, listNeighbor)

	elif (choice == "delete" or choice == "d"):
		del listNeighbor[:]
開發者ID:tommasoberlose,項目名稱:p2p_gnutella,代碼行數:33,代碼來源:Peer.py


注:本文中的Function.get_ipv4方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。