File: listen.py

package info (click to toggle)
pytris 0.98
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 132 kB
  • ctags: 70
  • sloc: python: 934; makefile: 42; sh: 41; ansic: 8
file content (14 lines) | stat: -rwxr-xr-x 295 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/usr/bin/python
# listen for UDP packets on given port
# usefull for debugging
import sys, socket

def rec(port):
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    s.bind(('', port))
    while 1:
        data, addr = s.recvfrom(1024)
        print `data`

rec(int(sys.argv[1]))