server--------------
#!/usr/bin/env python
# encoding: utf-8  
# Date: 2018/6/7


from socket import *

server = socket(AF_INET, SOCK_DGRAM)
server.bind(('127.0.0.1', 8080))


res1 = server.recvfrom(1024)
print('第一次:', res1)

res2 = server.recvfrom(1024)
print('第二次:', res2)

server.close()

client---------------------
#!/usr/bin/env python
# encoding: utf-8  
# Date: 2018/6/7


from socket import *
client = socket(AF_INET, SOCK_DGRAM)

client.sendto(b'hello', ('127.0.0.1', 8080))
client.sendto(b'world', ('127.0.0.1', 8080))

client.close()

相关文章:

  • 2022-01-14
  • 2022-12-23
  • 2022-12-23
  • 2021-05-18
  • 2022-12-23
  • 2021-12-27
  • 2021-11-30
猜你喜欢
  • 2022-02-10
  • 2021-11-07
  • 2021-09-27
  • 2019-06-16
  • 2021-12-25
  • 2021-11-11
  • 2021-08-25
相关资源
相似解决方案