UDP Networking Basics (questions)

BlitzMax Forums/BlitzMax Programming/UDP Networking Basics (questions)

You should add some reference to the official Internet Protocol RFCs; that would answer most of your question #2.

The choice of the port is mostly determined by the protocol you want to use or implement. IRC, for example, usually uses 6666, 6667 and 6668. SMTP is on port 25, POP3 on 110, NNTP on 119. HTTP is on 80, and 8080 is usually used for a local HTTP server (for testing purposes) or an HTTP proxy. However, all of these examples are TCP ports, and those are defined in the "Request For Comments" that describe commonly used protocols.

You only need administrator privileges (on Unix machines) to open listening servers on ports 1 - 1023. Clients can always try to open a connection through these ports (otherwise neither your email program nor your web browser would work without administrator privileges).

Once the connection is established, the sockets will eventually communicate through a different port anyway; that is managed by the operating system's sockets layer and completely transparent to the user/programmer.

There might be few reasons why one would want to use UDP rather than TCP, but usually you only want to use UDP when you don't really care for the (possible) responses from any peer computer. Reliable communication in real world applications is always handled via TCP. I guess only multiplayer games or chat clients and servers use UDP for certain (broadcasting) tasks.