Files
i2p.i2p/apps/sam/python/src/examples/raw_noblock.py
2004-08-02 14:34:06 +00:00

20 lines
525 B
Python

#! /usr/bin/env python
# ---------------------------------------------------
# raw_noblock.py: Non-blocking raw server
# ---------------------------------------------------
from i2p import socket
import time
S = socket.socket('Eve', socket.SOCK_RAW)
print 'Serving at:', S.dest
S.setblocking(False)
while True:
try:
data = S.recv(1000) # Read packet
print 'Got', data
except socket.BlockError: # No data available
pass
time.sleep(0.01) # Reduce CPU usage