0

I'm trying to send/recv raw ethernet under Ubuntu.

I've no problem running code in c through the terminal.

However when i've tried to convert the code to c++ using Netbeans IDE 6.9 it fails to open the raw socket. calling:

socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL))) == -1)

always return -1. error : "operation not permitted"

Ami DATA
  • 521
  • 2
  • 9
  • 14
  • Does it work if you run your application through terminal as root? – ollo Nov 03 '13 at 20:35
  • I figured out that running the code through the terminal using "sudo" solves the problem. Googling around I understand that there is a possibility to configure the Netbeans to do the same. I still did not manage to do so.. – Ami DATA Nov 04 '13 at 08:45

1 Answers1

0

You always need root permissions to send / receive something through raw sockets.

Here's how to configure NetBeans to run your application as root:

  1. Right click on project -> Properties -> Run
  2. Set Run Command to sudo "${OUTPUT_PATH}" (default is "${OUTPUT_PATH}")
ollo
  • 24,797
  • 14
  • 106
  • 155