In Python 3, the string (first) argument must be a byte type or buffer, not str. You will receive this error message if you specify the optional flags option. Change the data to:
q ata = b'UDP Test Data'
You might want to post a bug report in the python.org error tracking log. [EDIT: already filed as Dove noted]
...
>>> data = 'UDP Test Data' >>> udp.sendto(data, (hostname, port)) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: sendto() takes exactly 3 arguments (2 given) >>> udp.sendto(data, 0, (hostname, port)) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: sendto() argument 1 must be bytes or buffer, not str >>> data = b'UDP Test Data' >>> udp.sendto(data, 0, (hostname, port)) 13 >>> udp.sendto(data, (hostname, port)) 13
source share