title: How to read and send UDP packets on Mac OS X?
body: <p>I'm trying to create a program for read, given IP address and port (in this case on localhost), of UDP packets on Mac OS X (current version 10.9.5).</p>
  
  <p>The only one that gave me some useful data is tcpdump and nc (netcat), but it worked only 1 time.
  This is what I have done:</p>
  
  <p>1° terminal window</p>
  
  <pre><code>$ sudo tcpdump -i en0 -X -v 'udp port 60000'
  tcpdump: listening on en0, link-type EN10MB (Ethernet), capture size 65535 bytes
  * new packet with the string 'Hello' at the end *
  </code></pre>
  
  <p>2° terminal window</p>
  
  <pre><code>$ nc -u 192.168.1.67 60000
  Hello
  $
  </code></pre>
  
  <p>I don't have a lot of knowledge on this argument, so the final question is:</p>
  
  <p>If I need to create a program that needs to read any UDP packet given a port number and send UDP packets through the same port to any IP address, what's the easiest approach?
  I've tried to use also libpcap through C but without success.</p>