Skip to main content

You are here

Jeeudp -> display UDP messages on cli

1 post / 0 new
Jeroen
Jeeudp -> display UDP messages on cli

Playing for days with the ethernode, but did not understand the UDP multicast protocol. On Solaris I don't have a jeemon listener so I created / googled the following python solution. Perhaps you can use it.

Jeeudp sketch with UDP port set to 3000

#!/usr/bin/python import socket import struct import sys multicast_group = '239.192.74.66' server_address = ('', 3000) sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # Bind to the server address sock.bind(server_address) # Add the socket to the multicast group on all interfaces. group = socket.inet_aton(multicast_group) mreq = struct.pack('4sL', group, socket.INADDR_ANY) sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq) # Receive loop while True: print >>sys.stderr, '\nwaiting to receive message' data, address = sock.recvfrom(1024) print >>sys.stderr, 'received %s bytes from %s' % (len(data), address) print >>sys.stderr, repr(data) gives the following result: (I still have to check the output) waiting to receive message received 61 bytes from ('10.0.0.160', 23456)

'\x00\x00\x00\x0bJeeUdp\x00\x00\x02\x00\tRF12\x00\x00\x03\x00\x0c868.212\x00\x00\x04\x00\x07OK\x00\0739\x00\x00\x06\x00\x0f\x00\x01\x00\x04\x0e~\xe6\x00\x00\x00\x00'

regards, Jeroen

Premium Drupal Themes by Adaptivethemes