
UDP echo client using the WiConnect Library and mbed UDP Socket API.
udp_echo_server.py@0:0675bde9bdd5, 2014-08-23 (annotated)
- Committer:
- dan_ackme
- Date:
- Sat Aug 23 13:12:54 2014 +0000
- Revision:
- 0:0675bde9bdd5
- Child:
- 1:6053abbb65c5
Initial check-in
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dan_ackme | 0:0675bde9bdd5 | 1 | import socket |
dan_ackme | 0:0675bde9bdd5 | 2 | |
dan_ackme | 0:0675bde9bdd5 | 3 | ECHO_PORT = 7 |
dan_ackme | 0:0675bde9bdd5 | 4 | |
dan_ackme | 0:0675bde9bdd5 | 5 | sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) |
dan_ackme | 0:0675bde9bdd5 | 6 | sock.bind(('', ECHO_PORT)) |
dan_ackme | 0:0675bde9bdd5 | 7 | |
dan_ackme | 0:0675bde9bdd5 | 8 | while True: |
dan_ackme | 0:0675bde9bdd5 | 9 | data, address = sock.recvfrom(256) |
dan_ackme | 0:0675bde9bdd5 | 10 | print "datagram from", address |
dan_ackme | 0:0675bde9bdd5 | 11 | sock.sendto(data, address) |