Sockets on Ubuntu (operation not permitted)

前端 未结 2 1914
情书的邮戳
情书的邮戳 2021-01-03 03:35

I\'m newbee and just making my first steps in c++ under linux. So I have some task about sockets. I\'m following guides, especially this one. And code examples are not worki

2条回答
  •  执笔经年
    2021-01-03 04:01

    Some Unix systems won't allow you to create sockets everywhere. Make sure you have the right permissions and the right file system underneath. (Fat32 as it is used on sdcards in mobile phones won't allow additional flags to files and might get you into trouble) Finally on newer systems there are security things running like selinux which might block the creation of sockets.

    On my example I had to change

    #define SOCK_PATH "echo_socket"
    

    to

    #define SOCK_PATH "/dev/socket/echo_socket"
    

    after that it worked immediately. (executable started in root shell)

提交回复
热议问题