Daiki Kato / mbed-os-lychee

Dependents:   mbed-os-example-blinky-gr-lychee GR-Boads_Camera_sample GR-Boards_Audio_Recoder GR-Boads_Camera_DisplayApp ... more

Committer:
dkato
Date:
Fri Feb 02 05:42:23 2018 +0000
Revision:
0:f782d9c66c49
mbed-os for GR-LYCHEE

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dkato 0:f782d9c66c49 1 """
dkato 0:f782d9c66c49 2 mbed SDK
dkato 0:f782d9c66c49 3 Copyright (c) 2011-2013 ARM Limited
dkato 0:f782d9c66c49 4
dkato 0:f782d9c66c49 5 Licensed under the Apache License, Version 2.0 (the "License");
dkato 0:f782d9c66c49 6 you may not use this file except in compliance with the License.
dkato 0:f782d9c66c49 7 You may obtain a copy of the License at
dkato 0:f782d9c66c49 8
dkato 0:f782d9c66c49 9 http://www.apache.org/licenses/LICENSE-2.0
dkato 0:f782d9c66c49 10
dkato 0:f782d9c66c49 11 Unless required by applicable law or agreed to in writing, software
dkato 0:f782d9c66c49 12 distributed under the License is distributed on an "AS IS" BASIS,
dkato 0:f782d9c66c49 13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
dkato 0:f782d9c66c49 14 See the License for the specific language governing permissions and
dkato 0:f782d9c66c49 15 limitations under the License.
dkato 0:f782d9c66c49 16 """
dkato 0:f782d9c66c49 17 import socket
dkato 0:f782d9c66c49 18 import struct
dkato 0:f782d9c66c49 19
dkato 0:f782d9c66c49 20 MCAST_GRP = '224.1.1.1'
dkato 0:f782d9c66c49 21 MCAST_PORT = 5007
dkato 0:f782d9c66c49 22
dkato 0:f782d9c66c49 23 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
dkato 0:f782d9c66c49 24 sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
dkato 0:f782d9c66c49 25 sock.bind(('', MCAST_PORT))
dkato 0:f782d9c66c49 26 mreq = struct.pack("4sl", socket.inet_aton(MCAST_GRP), socket.INADDR_ANY)
dkato 0:f782d9c66c49 27
dkato 0:f782d9c66c49 28 sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq)
dkato 0:f782d9c66c49 29
dkato 0:f782d9c66c49 30 while True:
dkato 0:f782d9c66c49 31 print sock.recv(10240)