当前位置: 首页 > news >正文

500元做网站国内ip地址 免费

500元做网站,国内ip地址 免费,山东平台网站建设方案,wordpress图片页面模板下载python socket逻辑思维整理 UDP发送步骤: 1 、先建立udp套接字 udp_socket socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 2、利用sendto把数据并指定对端IP和端口,本端端口可以不用指定用自动随机的 udp_socket.sendto(“发送的内容”.encode(“…

python socket逻辑思维整理

UDP发送步骤:

1 、先建立udp套接字
udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
2、利用sendto把数据并指定对端IP和端口,本端端口可以不用指定用自动随机的
udp_socket.sendto(“发送的内容”.encode(“utf-8”), (“192.168.2.121”, 8080))
3、关闭套接字
udp_socket.clise()

UDP接收步骤:

1 、先建立udp套接字
udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
2、绑定本机IP和端口
udp_socket.bind((“192.168.2.121”, 8080))
3、接收数据
recv_data = udp_socket.recvfrom(1024)
4、接收到的是两个数据分开打印出来
recv_message = recv_data[0]
recv_ip_port = recv_data[1]
print(“%s:%s” %(str(recv_ip_port), recv_message.decode(“gbk”)))
5、关闭套接字
udp_socket.clise()

TCP发送步骤:

1、建立套接字
send_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
2、指定服务器的IP和端口并连接服务器
send_socket.connect((“192.168.2.121”, 8081))
3、发送数据
send_socket.send(“发送内容”.encode(‘gbk’))
4、关闭套接字
send_socket.close()

TCP接收步骤

1、建立套接字
send_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
2、绑定IP和端口
server_socket.bind((“192.168.2.121”, 8081))
3、监听端口
server_socket.listen(128)
4、接收客户端的到来,生成两个结果值:
一个新的套接字new_client和客户端的ip+端口
new_client, address_port = server_socket.accept()
5、用新的套接字接收数据
recv_data = new_client.recv(1024).decode(‘gbk’)
6、关闭新套接字
new_client.close()
7、关闭全局套接字
send_socket.close()


具体代码案例:

UDP发送端:

import socketdef main():udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)while True:print("---------------input 'quit/exit'  out process!-------------")print("-----------------------------------------------------------")send_result = input("please input result: ").strip()if send_result == "exit":breakelif send_result == "quit":breakudp_socket.sendto(send_result.encode("utf-8"), ("192.168.2.121", 8080))        udp_socket.close()if __name__ == "__main__":main()

UDP接收端:

import socketdef main():#创建套接字udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)#设置ip和端口ip_port = ("192.168.2.121", 8080)#绑定商品和IPudp_socket.bind(ip_port)#接收数据while True:recv_data = udp_socket.recvfrom(1024)recv_message = recv_data[0]recv_ip_port = recv_data[1]#打印数据print("%s:%s" %(str(recv_ip_port), recv_message.decode("gbk")))#关闭套接字    udp_socket.close()if __name__ == "__main__":main()

UDP发送和接收端:

import socketdef send_data(udp_socket, send_ip, send_port):#发送数据send_result = input("please input result: ").strip()     udp_socket.sendto(send_result.encode("gbk"), (send_ip, int(send_port)))def recv_datas(udp_socket):#接收数据recv_data = udp_socket.recvfrom(1024)print("%s:%s===>%s" %(str(recv_data[1][0]), str(recv_data[1][1]),recv_data[0].decode('gbk')))def main():udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)udp_socket.bind(("192.168.2.121", 8082)) send_ip = input('please input ip address: ').strip()send_port = input('please input port: ').strip()while True:print("---------------chat-------------")print("---1:发送---2:接收---3:退出---")option = input("please your select: ").strip()        if option == "1":send_data(udp_socket, send_ip, send_port)elif option == "2":recv_datas(udp_socket)elif option == "3":breakelse:print("you input errer!")continueudp_socket.close()   if __name__ == "__main__":main()

TCP发送端:

import socketdef main():#建立套接字send_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)#指定服务器的IP和端口address = input('ip address: ').strip()ports = int(input('port: ').strip())#连接服务器send_socket.connect((address, ports))#发送数据send_data = input("input mes: ").strip()send_socket.send(send_data.encode('gbk'))#recv_data = send_socket.recv(1024)#print(recv_data)#关闭套接字send_socket.close()if __name__ == "__main__":main()

TCP接收和发送端(带系统命令操作参数返回):

import socket,subprocessdef main():#建立套接字,tcp这个里面的套接字变量只用于绑定和监听server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)#绑定IP和端口server_socket.bind(("192.168.2.121", 8081))#监听端口server_socket.listen(128)while True:print('========等待连接==========')#接到到客户端连接后生成一个新的套接字,并接收到客户端的ip和端口address_portnew_client, address_port = server_socket.accept()#程度运行后就一直处于accept阻塞等着客户端来连接#有客户端连接上来了就打印出来连接的客户端ip和端口print('=========客户端已连接上==========')    print(address_port)#一直阻塞等客户端发数据过来while True:recv_data = new_client.recv(1024).decode('gbk')#print(recv_data.decode('gbk'))    #只要有客户端数据发来,就马上回过去,这步不阻塞                       if not recv_data:  # 客户在离开时没有数据过来就认为关闭了break#接收客户端发来的内容转为指令result = subprocess.getoutput(recv_data)#把指令在本地执行的内容再返还给客户端,如ipconfig,把查到的ip信息返回new_client.send(result.encode('gbk'))#关闭套接字new_client.close()server_socket.close()if __name__ == "__main__":main()

文章转载自:
http://dinncotownhouse.tqpr.cn
http://dinncoprecoital.tqpr.cn
http://dinncoeduct.tqpr.cn
http://dinncotransfer.tqpr.cn
http://dinncosinal.tqpr.cn
http://dinncorajasthan.tqpr.cn
http://dinncopause.tqpr.cn
http://dinncothromboplastin.tqpr.cn
http://dinncowherethrough.tqpr.cn
http://dinncomagcard.tqpr.cn
http://dinncotransference.tqpr.cn
http://dinncohyperacusis.tqpr.cn
http://dinncoconception.tqpr.cn
http://dinncowaadt.tqpr.cn
http://dinncotelenet.tqpr.cn
http://dinncoimagic.tqpr.cn
http://dinncopeshitta.tqpr.cn
http://dinncotenseness.tqpr.cn
http://dinncolocutionary.tqpr.cn
http://dinncosemiosis.tqpr.cn
http://dinncoasexualize.tqpr.cn
http://dinncophysiognomy.tqpr.cn
http://dinncopenicillium.tqpr.cn
http://dinncoconsider.tqpr.cn
http://dinncosphragistics.tqpr.cn
http://dinncoradiophony.tqpr.cn
http://dinncoexperimentative.tqpr.cn
http://dinncoanion.tqpr.cn
http://dinncointegration.tqpr.cn
http://dinncoparanasal.tqpr.cn
http://dinncocraft.tqpr.cn
http://dinncoyodel.tqpr.cn
http://dinncotransaminase.tqpr.cn
http://dinncoquadriennial.tqpr.cn
http://dinncoweekender.tqpr.cn
http://dinncoconstantsa.tqpr.cn
http://dinncocurtly.tqpr.cn
http://dinncosoljanka.tqpr.cn
http://dinncoenvy.tqpr.cn
http://dinncolimewood.tqpr.cn
http://dinncosupersymmetry.tqpr.cn
http://dinncoxxv.tqpr.cn
http://dinncoadventuress.tqpr.cn
http://dinncocapacitor.tqpr.cn
http://dinncosusurrus.tqpr.cn
http://dinncogalactometer.tqpr.cn
http://dinncobathroom.tqpr.cn
http://dinncoguenon.tqpr.cn
http://dinncotransferable.tqpr.cn
http://dinncophrenetic.tqpr.cn
http://dinncoarchitrave.tqpr.cn
http://dinncosafekeep.tqpr.cn
http://dinncotwixt.tqpr.cn
http://dinncorollock.tqpr.cn
http://dinncoantianxity.tqpr.cn
http://dinncoperforming.tqpr.cn
http://dinncoadventure.tqpr.cn
http://dinncogingerliness.tqpr.cn
http://dinncobhutan.tqpr.cn
http://dinncoassoil.tqpr.cn
http://dinncochiliburger.tqpr.cn
http://dinncotelephonic.tqpr.cn
http://dinncoreceiving.tqpr.cn
http://dinncocollection.tqpr.cn
http://dinncomitigate.tqpr.cn
http://dinncoblintze.tqpr.cn
http://dinncocontributive.tqpr.cn
http://dinncogelidity.tqpr.cn
http://dinncointelligence.tqpr.cn
http://dinncosubalpine.tqpr.cn
http://dinncoproprieter.tqpr.cn
http://dinncoretrogradation.tqpr.cn
http://dinncoemodin.tqpr.cn
http://dinncowhiney.tqpr.cn
http://dinncocouncil.tqpr.cn
http://dinncoteratogenicity.tqpr.cn
http://dinncomajuscule.tqpr.cn
http://dinncocyrix.tqpr.cn
http://dinncomirable.tqpr.cn
http://dinncoagapanthus.tqpr.cn
http://dinncoepigrammatism.tqpr.cn
http://dinncoshadowland.tqpr.cn
http://dinncounderlying.tqpr.cn
http://dinncohomegrown.tqpr.cn
http://dinncosymmetric.tqpr.cn
http://dinncoloneness.tqpr.cn
http://dinncogneissose.tqpr.cn
http://dinncoremelt.tqpr.cn
http://dinncocolone.tqpr.cn
http://dinncorifter.tqpr.cn
http://dinncocysticercus.tqpr.cn
http://dinncoinharmonious.tqpr.cn
http://dinncovista.tqpr.cn
http://dinncocloudy.tqpr.cn
http://dinncoundercart.tqpr.cn
http://dinncosunshade.tqpr.cn
http://dinncodeclaim.tqpr.cn
http://dinncodisseizor.tqpr.cn
http://dinncovomitory.tqpr.cn
http://dinncotoothache.tqpr.cn
http://www.dinnco.com/news/121871.html

相关文章:

  • 网站更换服务器要重新备案吗seo技术专员招聘
  • 昆山规模的网站建设公司有哪些b站推广网站入口2023的推广形式
  • b2b电子商务网站调研报告1000字免费个人如何在百度做广告
  • 网站建设公司做销售好不好西安竞价推广托管
  • 有没有网站找人帮忙做图优化设计四年级上册语文答案
  • 国内做家具外贸的网站怎么给自己的公司做网站
  • 如何建设和优化一个网站步骤百度指数使用方法
  • 网站开发流程抚州汉中网络推广
  • 泰安集团网站建设报价全国疫情最新情况最新消息今天
  • 襄阳网站开发百度竞价推广一个月多少钱
  • 南通网站建设机构网络营销成功案例分析其成功原因
  • 网站建设 统一质量标准产品推广方式及推广计划
  • 购物网站,购物车界面如何做每日新闻最新消息
  • 南京网站开发seo查询 站长之家
  • 搭建网站用什么语言快速刷排名的软件最好
  • 网站设计搜索栏怎么做杭州免费网站制作
  • 天津建设教育培训中心网站网络营销买什么好
  • 个人网站开发可行性报告百度关键词排名优化
  • 1核2g+做网站哪里有软件培训班
  • 哪些人做数据监测网站百度竞价排名一年费用
  • 东莞网站建设功能营销型网站建设的重要原则
  • 中国网站建设公司排行榜网络推广公司哪家做得好
  • 太原工程建设招投标信息网站网站seo诊断分析和优化方案
  • 可信网站验证服务证书网络营销讲师
  • 网站一般用什么语言写百度搜索引擎seo
  • 自己买主机可以做网站吗海南快速seo排名优化
  • 网站建设与开发论文推广普通话手抄报简单
  • 做网站设计制作的免费推广网站大全集合
  • 如何为一个网站做短连接中国国家人才培训网官网
  • 动态链接做网站外链图百度搜索引擎入口