title: How to open a UDP port?
body: <p>I have an assignment that I need to write a program that opens a port in the network, than I should check if the port is opened in another machine using nmap or netcat.</p>
  
  <p>Well, I already did that.. but I did it using socket, I created a socket then binded and keep listening, that's the only way I know to do it. is there a better way ? because my way doesn't seem write.. 
  Also, is opening a port for TCP is different then a port for UDP ? </p>
  
  <p>Note: I'm trying to figure out how to write a program that open a port in C/C++, but Python or Java are fine too..</p>
  
  <p>Edit: I'm fine with TCP, but still didn't figure out how to open a port for UDP. Since there's no "listen" in UDP, how am I supposed to keep the port open ? I wrote a program that creates a socket for UDP and binds it, but when I scan it with nmap, it says "open/filtered", how am I supposed to make it only Open ?</p>