Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Korakot Chaovavanich http://korakot.stumbleupon.com

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Using socket datagrams

From Jeff Bauer's recipe.
   1  
   2  # server.py
   3  import socket
   4  port = 8081
   5  s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
   6  s.bind(("", port))
   7  print "waiting on port:", port
   8  while 1:
   9      data, addr = s.recvfrom(1024)
  10      print data

   1  
   2  # client.py
   3  import socket
   4  port = 8081
   5  host = "localhost"
   6  s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
   7  s.bind(("", 0))
   8  s.sendto("Holy Guido! It's working.", (host, port))
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS