关于sendto : Permission denied

本文解决了UDP发送数据时出现的“sendto error : Permission denied”错误。通过设置套接字选项SO_REUSEADDR和SO_BROADCAST,成功解决了权限受限的问题。

遇到如题的问题,google了一番,找到了解决方法,写下来备用


问题:

udp发送数据时候报错sendto error  : Permission denied


改正方法:


在创建了套接字后,加上下列代码:

 int on=1;
  setsockopt(sockfd,SOL_SOCKET,SO_REUSEADDR | SO_BROADCAST,&on,sizeof(on));


重新编译,问题解决

PS C:\Users\Administrator> git commit -m "final: 完整修复所有依赖 + 深色模式 + toast" warning: could not open directory 'Application Data/': Permission denied warning: could not open directory 'Cookies/': Permission denied warning: could not open directory 'Local Settings/': Permission denied warning: could not open directory 'My Documents/': Permission denied warning: could not open directory 'NetHood/': Permission denied warning: could not open directory 'PrintHood/': Permission denied warning: could not open directory 'Recent/': Permission denied warning: could not open directory 'SendTo/': Permission denied warning: could not open directory 'Templates/': Permission denied warning: could not open directory '「开始」菜单/': Permission denied On branch main Initial commit Untracked files: (use "git add <file>..." to include in what will be committed) .Ld9VirtualBox/ .MUMUVMM/ .android/ .cache/ .config/ .cursor/ .dbclient/ .dotnet/ .env.example .env.local .gitconfig .gitignore .keras/ .matplotlib/ .modelscope/ .node_repl_history .npmrc .nuget/ .ollama/ .ssh/ .thumbnails/ .trae-aicc/ .trae-cn/ .vscode/ .xdebug-debugclient.hist 4 AppData/ ComfyUI-Manager/ Contacts/ Desktop/ Documents/ Downloads/ Favorites/ FolderA_Nums.txt FolderB_Nums.txt Links/ Music/ My WangWang/ NTUSER.DAT NTUSER.DAT{27a3eb2d-8202-1242-bae3-cd0414a4f6f3}.TM.blf NTUSER.DAT{27a3eb2d-8202-1242-bae3-cd0414a4f6f3}.TMContainer00000000000000000001.regtrans-ms NTUSER.DAT{27a3eb2d-8202-1242-bae3-cd0414a4f6f3}.TMContainer00000000000000000002.regtrans-ms OneDrive/ Pictures/ README.md Saved Games/ Searches/ WPS Cloud Files/ WPSDrive/ WeChatProjects/ comfyui-launcher/ components.json deplister.exe dev/ ext/ extras/ gi-demo/ glib-2.dll gmodule-2.dll hun-jian/ icudt72.dll icuin72.dll icuio72.dll icuuc72.dll lib/ libcrypto-3-x64.dll libenchant2.dll libpq.dll libsasl.dll libsodium.dll libsqlite3.dll libssh2.dll libssl-3-x64.dll license.txt mumu_boot.txt news.txt next.config.mjs nghttp2.dll node_modules/ ntuser.dat.LOG1 ntuser.dat.LOG2 ntuser.ini ollama_install.sh package-lock.json package.json phar.phar.bat pharcommand.phar php-cgi.exe php-win.exe php.exe php.ini-development php.ini-production php8apache2_4.dll php8embed.lib php8phpdbg.dll php8ts.dll phpdbg.exe pnpm-lock.yaml postcss.config.mjs readme-redist-bins.txt snapshot.txt source/ tsconfig.json nothing added to commit but untracked files present (use "git add" to track) PS C:\Users\Administrator> git push -f origin main 这是什么错误
最新发布
11-27
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值