Python UDP broadcast permissionerror: [Errno] Permission denied

Source: Internet
Author: User

/********************************************************************** * Python UDP broadcast PermissionError: [ Errno 13] Permission denied*Description:*use Python3 to do UDP broadcast, encountered this permission problem, then a burst of surprise, first look*to this problem of no permissions. * * 2016-12-10Shenzhen Nanshan Ping Shan village Zengjianfeng*********************************************************************/One, reference document: Python socket.error: [Errno13] Permission denied http:stackoverflow.com/questions/11457676/python-socket-error-errno-13-permission-denied two, error:1. Error symptom: [[email protected]~]#python main.pyFdsaf Traceback (most recent): File"main.py", line 11,inch<module>S.sendto ('ZENGJF'. Encode ('Utf-8'), address) Permissionerror: [Errno13] Permission denied [[email protected]~]#2. Error reason: Set the so_broadcast option,ifYou actually mean-to-send to a broadcast address:s.setsockopt (socket. Sol_socket, SOCKET. So_broadcast,1)    3. Test code:ImportSocket Address= ('255.255.255.255', 50000) s=Socket.socket (socket.af_inet, socket. SOCK_DGRAM) s.setsockopt (socket. Sol_socket, SOCKET. So_broadcast,1)         whiletrue:msg=input ()if  notmsg: BreakS.sendto ('ZENGJF'. Encode ('Utf-8'), address) s.close ()

Python UDP broadcast permissionerror: [Errno] Permission denied

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.